bass#
Bass diffusion model for product adoption forecasting.
The recommended entry point is BassModel, which wraps the model in a
ModelBuilder interface with standard
.fit(), .save(), and .load() methods.
The lower-level create_bass_model() and BassPriors are still
available for users who need the raw pm.Model without the class wrapper.
Examples#
Fit a single-product model from an array of adoption counts:
import numpy as np
from pymc_marketing.bass import BassModel
model = BassModel()
idata = model.fit(data=np.random.poisson(lam=100, size=50))
Generate synthetic data from the prior, then fit the model:
import xarray as xr
import pymc as pm
ds = xr.Dataset({"T": np.arange(50)})
model = BassModel()
model.build_model(data=ds)
with model.model:
prior = pm.sample_prior_predictive(draws=50, random_seed=42)
y_sim = prior.prior["y"].sel(draw=0, chain=0)
idata = model.fit(data=y_sim.values)
Modules