MVITS#
- class pymc_marketing.customer_choice.mv_its.MVITS(existing_sales, saturated_market=True, model_config=None, sampler_config=None)[source]#
Multivariate Interrupted Time Series class.
Class to perform a multivariate interrupted time series analysis with the specific intent of determining where the sales of a new product came from.
- Parameters:
- existing_sales
listofstr The names of the existing products.
- saturated_marketbool, optional
Whether the market is saturated or not. If True, the sum of the beta’s will be 1. Else, the sum of the beta’s will be less than 1 with the remaining sales attributed to the new product.
- model_config
dict, optional The model configuration. If None, the default model configuration will be used.
- sampler_config
dict, optional The sampler configuration. If None, the default sampler configuration will be used.
- existing_sales
Methods
MVITS.__init__(existing_sales[, ...])Initialize model configuration and sampler configuration for the model.
MVITS.attrs_to_init_kwargs(attrs)Convert the attributes of the InferenceData object to the __init__ kwargs.
MVITS.build_from_idata(idata)Build model from the InferenceData object.
MVITS.build_model(X, y, **kwargs)Build a PyMC model for a multivariate interrupted time series analysis.
MVITS.calculate_counterfactual([random_seed])Calculate the counterfactual scenario of never releasing the new product.
MVITS.causal_impact([variable])Calculate the causal impact of the new product on the existing products.
MVITS.create_fit_data(X, y)Create the fit_data group based on the input data.
Create the attributes for the InferenceData object.
MVITS.fit(X[, y, progressbar, random_seed])Fit a model using the data passed as a parameter.
MVITS.graphviz(**kwargs)Get the graphviz representation of the model.
Inform the default prior based on the data.
MVITS.load(fname)Create a ModelBuilder instance from a file.
MVITS.load_from_idata(idata)Create a ModelBuilder instance from an InferenceData object.
Plot the inferred causal impact of the new product on the existing products.
MVITS.plot_causal_impact_sales([variable, ax])Plot causal impact of sales.
MVITS.plot_counterfactual([variable, ...])Plot counterfactual scenario.
MVITS.plot_data([plot_total_sales, ax])Plot the observed data.
MVITS.plot_fit([variable, plot_total_sales, ax])Plot the model fit (posterior predictive) of the existing products.
Perform transformation on the model after sampling.
MVITS.predict([X, extend_idata])Use a model to predict on unseen data and return point prediction of all the samples.
MVITS.predict_posterior([X, extend_idata, ...])Generate posterior predictive samples on unseen data.
MVITS.predict_proba([X, extend_idata, combined])Alias for
predict_posterior, for consistency with scikit-learn probabilistic estimators.MVITS.sample(X, y[, random_seed, ...])Sample all the things.
MVITS.sample_posterior_predictive([X, ...])Sample from the model's posterior predictive distribution.
MVITS.sample_prior_predictive([X, y, ...])Sample from the model's prior predictive distribution.
MVITS.save(fname)Save the model's inference data to a file.
MVITS.set_idata_attrs([idata])Set attributes on an InferenceData object.
MVITS.table(**model_table_kwargs)Get the summary table of the model.
Attributes
Xdefault_model_configDefault model configuration.
default_sampler_configDefault sampler configuration.
fit_resultGet the posterior fit_result.
idGenerate a unique hash value for the model.
output_varThe output variable of the model.
posteriorposterior_predictivepredictionspriorprior_predictiveversiony