Skip to content

Commit b10f1f1

Browse files
Fix model_builder docstrings (#861)
* Fix model_builder docstrings * Fix whitespace error --------- Co-authored-by: Juan Orduz <juanitorduz@gmail.com>
1 parent d759eb3 commit b10f1f1

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

pymc_marketing/model_builder.py

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def __init__(
7272
sampler_config : Dictionary, optional
7373
dictionary of parameters that initialise sampler configuration.
7474
Class-default defined by the user default_sampler_config method.
75+
7576
Examples
7677
--------
7778
>>> class MyModel(ModelBuilder):
@@ -150,6 +151,7 @@ def default_model_config(self) -> dict:
150151
"""
151152
Returns a class default config dict for model builder if no model_config is provided on class initialization
152153
Useful for understanding structure of required model_config to allow its customization by users
154+
153155
Examples
154156
--------
155157
>>> @classmethod
@@ -436,28 +438,28 @@ def fit(
436438
Fit a model using the data passed as a parameter.
437439
Sets attrs to inference data of the model.
438440
439-
440441
Parameters
441442
----------
442-
X : array-like if sklearn is available, otherwise array, shape (n_obs, n_features)
443-
The training input samples.
444-
y : array-like if sklearn is available, otherwise array, shape (n_obs,)
445-
The target values (real numbers).
443+
X : array-like | array, shape (n_obs, n_features)
444+
The training input samples. If scikit-learn is available, array-like, otherwise array.
445+
y : array-like | array, shape (n_obs,)
446+
The target values (real numbers). If scikit-learn is available, array-like, otherwise array.
446447
progressbar : bool
447-
Specifies whether the fit progressbar should be displayed
448-
predictor_names: Optional[List[str]] = None,
449-
Allows for custom naming of predictors given in a form of 2dArray
448+
Specifies whether the fit progress bar should be displayed.
449+
predictor_names : Optional[List[str]] = None,
450+
Allows for custom naming of predictors when given in a form of a 2D array.
450451
Allows for naming of predictors when given in a form of np.ndarray, if not provided
451452
the predictors will be named like predictor1, predictor2...
452453
random_seed : Optional[RandomState]
453-
Provides sampler with initial random seed for obtaining reproducible samples
454+
Provides sampler with initial random seed for obtaining reproducible samples.
454455
**kwargs : Any
455456
Custom sampler settings can be provided in form of keyword arguments.
456457
457458
Returns
458459
-------
459460
self : az.InferenceData
460-
returns inference data of the fitted model.
461+
Returns inference data of the fitted model.
462+
461463
Examples
462464
--------
463465
>>> model = MyModel()
@@ -522,9 +524,10 @@ def predict(
522524
523525
Parameters
524526
----------
525-
X_pred : array-like if sklearn is available, otherwise array, shape (n_pred, n_features)
526-
The input data used for prediction.
527-
extend_idata : Boolean determining whether the predictions should be added to inference data object.
527+
X_pred : array-like | array, shape (n_pred, n_features)
528+
The input data used for prediction. If scikit-learn is available, array-like, otherwise array.
529+
extend_idata : Boolean
530+
Determine whether the predictions should be added to inference data object.
528531
Defaults to True.
529532
**kwargs: Additional arguments to pass to sample_posterior_predictive method
530533
@@ -575,9 +578,11 @@ def sample_prior_predictive(
575578
samples : int
576579
Number of samples from the prior parameter distributions to generate.
577580
If not set, uses sampler_config['draws'] if that is available, otherwise defaults to 500.
578-
extend_idata : Boolean determining whether the predictions should be added to inference data object.
581+
extend_idata : Boolean
582+
Determine whether the predictions should be added to inference data object.
579583
Defaults to True.
580-
combined: Combine chain and draw dims into sample. Won't work if a dim named sample already exists.
584+
combined: Boolean
585+
Combine chain and draw dims into sample. Won't work if a dim named sample already exists.
581586
Defaults to True.
582587
**kwargs: Additional arguments to pass to pymc.sample_prior_predictive
583588
@@ -624,9 +629,11 @@ def sample_posterior_predictive(
624629
----------
625630
X_pred : array, shape (n_pred, n_features)
626631
The input data used for prediction using prior distribution..
627-
extend_idata : Boolean determining whether the predictions should be added to inference data object.
632+
extend_idata : Boolean
633+
Determine whether the predictions should be added to inference data object.
628634
Defaults to True.
629-
combined: Combine chain and draw dims into sample. Won't work if a dim named sample already exists.
635+
combined: Boolean
636+
Combine chain and draw dims into sample. Won't work if a dim named sample already exists.
630637
Defaults to True.
631638
**sample_posterior_predictive_kwargs: Additional arguments to pass to pymc.sample_posterior_predictive
632639
@@ -704,18 +711,21 @@ def predict_posterior(
704711
705712
Parameters
706713
----------
707-
X_pred : array-like if sklearn is available, otherwise array, shape (n_pred, n_features)
708-
The input data used for prediction.
709-
extend_idata : Boolean determining whether the predictions should be added to inference data object.
714+
X_pred : array-like | array, shape (n_pred, n_features)
715+
The input data used for prediction. If scikit-learn is available, array-like, otherwise array.
716+
extend_idata : Boolean
717+
Determine whether the predictions should be added to inference data object.
710718
Defaults to True.
711-
combined: Combine chain and draw dims into sample. Won't work if a dim named sample already exists.
719+
combined: Boolean
720+
Combine chain and draw dims into sample. Won't work if a dim named sample already exists.
712721
Defaults to True.
713722
**kwargs: Additional arguments to pass to sample_posterior_predictive method
714723
715724
Returns
716725
-------
717-
y_pred : DataArray, shape (n_pred, chains * draws) if combined is True, otherwise (chains, draws, n_pred)
718-
Posterior predictive samples for each input X_pred
726+
y_pred : DataArray
727+
Posterior predictive samples for each input X_pred.
728+
Shape is (n_pred, chains * draws) if combined is True, otherwise (chains, draws, n_pred).
719729
"""
720730

721731
X_pred = self._validate_data(X_pred)

0 commit comments

Comments
 (0)