clvkit.MBGNBD#

class MBGNBD[source]#

Bases: object

The MBG/NBD transaction-flow model — BG/NBD’s never-returner variant.

The same three verbs as BGNBD, so it drops into the same places:

model = MBGNBD().fit(cb)
model.predict(t=12).to_pandas()      # expected purchases in the next 12 time units
model.probability_alive().to_pandas()

Reach for it over BGNBD when a large share of the base never repeated: BG/NBD calls every one of those customers alive with probability 1, while this model lets them have died right after their first purchase.

Fitting is maximum likelihood — no sampler, no priors, no convergence diagnostics to read.

fit(cb)[source]#

Estimate (r, alpha, a, b) by maximum likelihood on cb.

The optimiser works on log parameters 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:

MBGNBD

predict(t, cb=None)[source]#

Expected purchases in the next t time units, per customer.

t is in the fitted base’s own time_unit. Pass cb to score a different customer base than the one fitted on — it must carry the same time_unit, or the answer would silently be in the wrong units.

Parameters:
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