innovate.diffuse.bass module¶
- class innovate.diffuse.bass.BassModel(covariates: Sequence[str] = None, t_event: float = None)[source]¶
Bases:
DiffusionModel
Implementation of the Bass Diffusion Model. This is a wrapper around the DualInfluenceGrowth dynamics model.
- bounds(t: Sequence[float], y: Sequence[float]) Dict[str, tuple] [source]¶
Return parameter bounds for the Bass model, including covariate effects.
- Parameters:
t (Sequence[float]) – Sequence of time points.
y (Sequence[float]) – Observed cumulative adoption values.
- Returns:
Dictionary mapping parameter names to (lower, upper) bounds. Base parameters “p”, “q”, and “m” have fixed bounds; covariate-related parameters are unbounded.
- Return type:
Dict[str, tuple]
- differential_equation(t, y, params, covariates, t_eval)[source]¶
Defines the Bass model’s differential equation, incorporating covariate effects if provided.
At each time point, adjusts the innovation, imitation, and market size parameters by linearly combining base values with covariate contributions, then computes the instantaneous growth rate using the underlying DualInfluenceGrowth model.
- Parameters:
t – Current time point.
y – Current cumulative adoption value.
params – Sequence of model parameters, including base and covariate coefficients.
covariates – Optional dictionary mapping covariate names to their time series values.
t_eval – Sequence of time points for covariate interpolation.
- Returns:
The instantaneous adoption rate at time t.
- initial_guesses(t: Sequence[float], y: Sequence[float]) Dict[str, float] [source]¶
Returns initial guesses for the model parameters.
- property param_names: Sequence[str]¶
Return the list of parameter names for the Bass model, including base parameters and covariate-related coefficients.
- Returns:
List of parameter names, with covariate effects included if applicable.
- Return type:
names (Sequence[str])
- property params_: Dict[str, float]¶
Returns a dictionary of fitted model parameters.
- predict(t: Sequence[float], covariates: Dict[str, Sequence[float]] = None) Sequence[float] [source]¶
Predicts cumulative adoption over time using the Bass diffusion model.
- Parameters:
t (Sequence[float]) – Sequence of time points at which to predict cumulative adoption.
covariates (Dict[str, Sequence[float]], optional) – Optional time series of covariate values affecting model parameters.
- Returns:
Predicted cumulative adoption at each time point in t.
- Return type:
Sequence[float]
- Raises:
RuntimeError – If the model parameters have not been set (i.e., the model is not fitted).
- predict_adoption_rate(t: Sequence[float], covariates: Dict[str, Sequence[float]] = None) Sequence[float] [source]¶
Predicts the rate of adoption (new adoptions per unit of time).
- score(t: Sequence[float], y: Sequence[float], covariates: Dict[str, Sequence[float]] = None) float [source]¶
Compute the coefficient of determination (R²) between observed and predicted values.
- Parameters:
y (Sequence[float]) – Observed cumulative adoption values.
- Returns:
R² score indicating the proportion of variance explained by the model predictions.
- Return type:
float