Skip to content

Commit e6f844f

Browse files
authored
Various MMM small documentation fixes (#854)
* make nb ruff astral-sh/ruff-vscode#546 * fix docs * fix quickstart * add types
1 parent a98815f commit e6f844f

File tree

4 files changed

+30
-19
lines changed

4 files changed

+30
-19
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ repos:
1111
- --exclude=docs/
1212
- --exclude=scripts/
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.5.3
14+
rev: v0.5.4
1515
hooks:
1616
- id: ruff
17-
types_or: [ python, pyi, jupyter ]
17+
types_or: [python, pyi, jupyter]
1818
args: ["--fix", "--output-format=full"]
1919
exclude: ^docs/source/notebooks/clv/dev/
2020
- id: ruff-format
21-
types_or: [ python, pyi, jupyter ]
21+
types_or: [python, pyi, jupyter]
2222
exclude: ^docs/source/notebooks/clv/dev/
2323
- repo: https://github.com/pre-commit/mirrors-mypy
2424
rev: v1.10.1

docs/source/index.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,30 +111,36 @@ Start VS Code and ensure that the "Jupyter" extension is installed. Press Ctrl +
111111

112112
```python
113113
import pandas as pd
114-
from pymc_marketing.mmm import DelayedSaturatedMMM
114+
115+
from pymc_marketing.mmm import (
116+
GeometricAdstock,
117+
LogisticSaturation,
118+
MMM,
119+
)
115120

116121

117122
data_url = "https://raw.githubusercontent.com/pymc-labs/pymc-marketing/main/data/mmm_example.csv"
118123
data = pd.read_csv(data_url, parse_dates=['date_week'])
119124

120-
mmm = DelayedSaturatedMMM(
125+
mmm = MMM(
126+
adstock=GeometricAdstock(l_max=8),
127+
saturation=LogisticSaturation(),
121128
date_column="date_week",
122129
channel_columns=["x1", "x2"],
123130
control_columns=[
124131
"event_1",
125132
"event_2",
126133
"t",
127134
],
128-
adstock_max_lag=8,
129135
yearly_seasonality=2,
130136
)
131137
```
132138

133139
Initiate fitting and get a visualization of some of the outputs with:
134140

135141
```python
136-
X = data.drop('y',axis=1)
137-
y = data['y']
142+
X = data.drop("y",axis=1)
143+
y = data["y"]
138144
mmm.fit(X,y)
139145
mmm.plot_components_contributions();
140146
```

pymc_marketing/mmm/delayed_saturated_mmm.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,20 +1683,22 @@ def sample_posterior_predictive(
16831683
Sample from the model's posterior predictive distribution.
16841684
16851685
Parameters
1686-
---------
1686+
----------
16871687
X_pred : array, shape (n_pred, n_features)
16881688
The input data used for prediction.
1689-
extend_idata : Boolean determining whether the predictions should be added to inference data object.
1689+
extend_idata : bool, optional
1690+
Boolean determining whether the predictions should be added to inference data object. Defaults to True.
1691+
combined: bool, optional
1692+
Combine chain and draw dims into sample. Won't work if a dim named sample already exists. Defaults to True.
1693+
include_last_observations: bool, optional
1694+
Boolean determining whether to include the last observations of the training data in order to carry over
1695+
costs with the adstock transformation. Assumes that X_pred are the next predictions following the
1696+
training data.Defaults to False.
1697+
original_scale: bool, optional
1698+
Boolean determining whether to return the predictions in the original scale of the target variable.
16901699
Defaults to True.
1691-
combined: Combine chain and draw dims into sample. Won't work if a dim named sample already exists.
1692-
Defaults to True.
1693-
include_last_observations: Boolean determining whether to include the last observations of the training
1694-
data in order to carry over costs with the adstock transformation.
1695-
Assumes that X_pred are the next predictions following the training data.
1696-
Defaults to False.
1697-
original_scale: Boolean determining whether to return the predictions in the original scale
1698-
of the target variable. Defaults to True.
1699-
**sample_posterior_predictive_kwargs: Additional arguments to pass to pymc.sample_posterior_predictive
1700+
**sample_posterior_predictive_kwargs
1701+
Additional arguments to pass to pymc.sample_posterior_predictive
17001702
17011703
Returns
17021704
-------

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ ignore = [
112112
[tool.ruff.lint.pycodestyle]
113113
max-line-length = 120
114114

115+
[tool.ruff]
116+
extend-include = ["*.ipynb"]
117+
115118
[tool.pytest.ini_options]
116119
addopts = [
117120
"-v",

0 commit comments

Comments
 (0)