clvkit.CohortSurvival#
- class CohortSurvival(transaction_model=None)[source]#
Bases:
objectSurvival curves for a non-contractual base, from a fitted P(alive).
>>> curve = CohortSurvival().fit(cb).predict() >>> curve.to_pandas()["survival"] >>> curve.plot()
Defaults to BGNBD(); pass any model answering fit and probability_alive to swap it, e.g. CohortSurvival(MBGNBD()).
- Parameters:
transaction_model (TransactionModel | None)
- fit(cb)[source]#
Fit the transaction model on cb — everything else is aggregation.
- Parameters:
cb (CustomerBase)
- Return type:
- predict(*, period=None)[source]#
Aggregate the fitted P(alive) into a survival curve.
period is the cohort grain, any pandas offset alias (“M”, “Q”, “Y”). It defaults to the base’s own time_unit, which is the finest grain the RFM summary can resolve — coarsen it when that leaves too many cohorts to read (see opinions.md).
- Parameters:
period (str | None)
- Return type:
SurvivalCurve