Skip to content

Commit 38d5f12

Browse files
committed
Updating doctest
1 parent c1dfd90 commit 38d5f12

File tree

2 files changed

+5
-33
lines changed

2 files changed

+5
-33
lines changed

causalpy/experiments/change_point_detection.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,6 @@
8282
- New handler types can be easily added (e.g., multiple intervention times)
8383
- Code is maintainable and testable with clear separation of concerns
8484
85-
Usage Examples
86-
--------------
87-
Known treatment time (traditional approach):
88-
89-
>>> result = cp.ChangePointDetection(
90-
... data=df,
91-
... time_range=None
92-
... formula="y ~ 1 + t + C(month)",
93-
... model=cp.pymc_models.LinearChangePointDetection(),
94-
... )
95-
9685
The module automatically selects the appropriate handler based on the treatment_time
9786
parameter and model type, providing a seamless user experience while maintaining
9887
the flexibility to handle diverse analytical scenarios.
@@ -138,18 +127,18 @@ class ChangePointDetection(BaseExperiment):
138127
... .assign(date=lambda x: pd.to_datetime(x["date"]))
139128
... .set_index("date")
140129
... )
141-
>>> treatment_time = pd.to_datetime("2017-01-01")
142130
>>> seed = 42
143-
>>> result = cp.InterruptedTimeSeries(
131+
>>> result = cp.experiments.change_point_detection.ChangePointDetection(
144132
... df,
145-
... treatment_time,
133+
... time_range=None,
146134
... formula="y ~ 1 + t + C(month)",
147-
... model=cp.pymc_models.LinearRegression(
135+
... model=cp.pymc_models.LinearChangePointDetection(
136+
... cp_effect_type="level",
148137
... sample_kwargs={
149138
... "target_accept": 0.95,
150139
... "random_seed": seed,
151140
... "progressbar": False,
152-
... }
141+
... },
153142
... ),
154143
... )
155144
"""

causalpy/experiments/interrupted_time_series.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,6 @@
8686
--------------
8787
Known treatment time (traditional approach):
8888
89-
>>> result = cp.InterruptedTimeSeries(
90-
... data=df,
91-
... treatment_time=pd.to_datetime("2017-01-01"), # Known intervention
92-
... formula="y ~ 1 + t + C(month)",
93-
... model=cp.pymc_models.LinearRegression(),
94-
... )
95-
96-
Unknown treatment time (inference approach):
97-
98-
>>> model = cp.pymc_models.InterventionTimeEstimator(treatment_effect_type="level")
99-
>>> result = cp.InterruptedTimeSeries(
100-
... data=df,
101-
... treatment_time=None, # Let model infer the time
102-
... formula="y ~ 1 + t + C(month)",
103-
... model=model,
104-
... )
105-
10689
The module automatically selects the appropriate handler based on the treatment_time
10790
parameter and model type, providing a seamless user experience while maintaining
10891
the flexibility to handle diverse analytical scenarios.

0 commit comments

Comments
 (0)