Skip to main content

Cure rate models for time-lagged conversion analysis

Project description

curerate

curerate is a Python library for fitting cure rate models — statistical models for time-lagged conversions where some fraction of the population will never convert.

It is a modernised fork of convoys by Erik Bernhardsson.

Installation

pip install curerate

Quickstart

import curerate as cr

# Your DataFrame has timestamp columns — curerate handles the rest
model = cr.ConversionModel(dist="weibull")
model.fit(
    df,
    created="signed_up_at",
    converted="converted_at",
    group="plan",           # optional
)

# Predict conversion rates at specific time points
model.predict(t=[7, 14, 30, 60, 90])

# What fraction will ever convert?
model.predict_final()

# Summary table
model.summary()

# Plot conversion curves
model.plot(t_max=90)

API

ConversionModel(dist, mcmc, hierarchical)

Parameter Default Description
dist "weibull" Distribution: "exponential", "weibull", "gamma", "generalized_gamma", or "kaplan_meier"
mcmc False Enable MCMC sampling for confidence intervals
hierarchical True Regularise parameters across groups

model.fit(df, *, created, converted, group=None, now=None, t_unit="days")

Fits the model to a DataFrame. Rows where converted is NaT/NaN are treated as censored (not yet converted).

model.predict(t, group=None, ci=None) → DataFrame

Returns predicted conversion rates at times t. Columns: t, group, conversion, and optionally conversion_low/conversion_high when ci is set and mcmc=True.

model.predict_final(ci=None) → DataFrame

Returns the asymptotic conversion rate (the fraction that will ever convert). Columns: group, conversion, and optionally conversion_low/conversion_high.

model.summary()

Prints a summary table with per-group statistics.

model.plot(t_max=90, ci=None, ax=None) → Axes

Plots conversion curves for all groups. Returns a matplotlib Axes.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

curerate-0.2.0.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

curerate-0.2.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file curerate-0.2.0.tar.gz.

File metadata

  • Download URL: curerate-0.2.0.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for curerate-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d468057f654ccaa99df06cf19d83dd8d18c3927ea5fe4372b9137cc7d68bf0e3
MD5 b77dd0ba04fa600ca2a222eb75d2a4ec
BLAKE2b-256 d1c58d3cb509c3563549f9a16c67833544e905c7ed14e0471f0b7e79472214e3

See more details on using hashes here.

File details

Details for the file curerate-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: curerate-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for curerate-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7e0256402b47cfc8aeaa0f155a6f30f72727f65a97d41ef183d246235cd343d
MD5 cf1dc489160519717b71d8171a353cc6
BLAKE2b-256 7545bcaf8ee371dc42e204bb35ebb3d7e9e9a1a1bdfa2212bbb38291cde321db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page