clvkit.BGNBD#
- class BGNBD[source]#
Bases:
objectThe BG/NBD transaction-flow model.
Three verbs, no aliases:
model = BGNBD().fit(cb) model.predict(t=12).to_pandas() # expected purchases in the next 12 time units model.probability_alive().to_pandas()
Fitting is maximum likelihood — no sampler, no priors, no convergence diagnostics to read.
- fit(cb)[source]#
Estimate
(r, alpha, a, b)by maximum likelihood oncb.The optimiser works on
logparameters so the search is unconstrained while the parameters stay strictly positive, which is what the gamma and beta priors of section 3 require.- Parameters:
cb (CustomerBase)
- Return type:
- predict(t, cb=None)[source]#
Expected purchases in the next
ttime units, per customer.tis in the fitted base’s owntime_unit. Passcbto score a different customer base than the one fitted on — it must carry the sametime_unit, or the answer would silently be in the wrong units.- Parameters:
t (float)
cb (CustomerBase | None)
- Return type:
Prediction
- probability_alive(cb=None)[source]#
P(each customer is still active) at the base’s observation period end.
- Parameters:
cb (CustomerBase | None)
- Return type:
Prediction