Skip to content

MLflow integration for BassModel #2588

@williambdean

Description

@williambdean

Track MLflow integration for the BassModel.

What already works (free lunch)

pymc_marketing.mlflow.autolog() patches pm.sample, which BassModel.fit() calls internally. This gives us:

  • Version logging (PyMC-Marketing, PyMC, ArviZ versions)
  • Model diagnostics (divergences, sampling time, draws, chains)
  • ArviZ summary table
  • Model graph PDF
  • Metadata of inputs
  • InferenceData artifact

No Bass-specific code needed for any of the above.

What would need explicit support

This should build off plotting methods on BassModel and an updated notebook. The workflow would be:

import mlflow
import pymc_marketing.mlflow
pymc_marketing.mlflow.autolog(log_bass=True)

model = BassModel()

with mlflow.start_run():
    idata = model.fit(data=y)
    pp = model.sample_posterior_predictive(X=future)

    fig = model.plot_adoption_curve()
    mlflow.log_figure(fig, "adoption_curve.png")

    fig = model.plot_decomposition()
    mlflow.log_figure(fig, "decomposition.png")

Specific additions needed in pymc_marketing/mlflow.py:

  1. Patch BassModel.fit — logs model config (priors for m, p, q, likelihood), model type, and saves idata.nc (pattern already used by MMM and CLV)
  2. log_bass_configuration helper — logs the prior configuration for reproducibility

Dependencies

  • BassModel plotting methods (for mlflow.log_figure)
  • Updated notebook showcasing the full MLflow workflow

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bass modelDealing with the Bass Defusion modeldocsImprovements or additions to documentationenhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions