Skip to main content

lifetime-value

A library to help finding the lifetime value of a group of subjects by calculating the average values through time.

Installation

You can install lifetime-value from PyPI using pip like this:

pip install lifetime-value

Usage

The following example code:

import datetime
import pandas as pd
import lifetime_value as ltv

event_log_df = pd.DataFrame({
    'subject_id': ['user_a', 'user_a', 'user_a', 'user_b', 'user_b', 'user_a'],
    'date': ['2021-01-04', '2021-01-04', '2021-01-10', '2021-01-05', '2021-01-07', '2021-01-07'],
    'type': ['registration', 'conversion', 'conversion', 'registration', 'conversion', 'conversion'],
    'value': [0, 10, 5, 0, 7, 1],
})
event_log_df['date'] = [datetime.datetime.strptime(item, "%Y-%m-%d").date() for item in event_log_df.date]

df_result = ltv.from_event_log(event_log_df, confidence_level=0.8)
print(df_result)

Will return:

   time  value  confidence_interval_left_bound  confidence_interval_right_bound
0     0    5.0                             0.0                             10.0
1     1    5.0                             0.0                             10.0
2     2    8.5                             7.0                             10.0
3     3    9.0                             7.0                             11.0
4     4    9.0                             7.0                             11.0
5     5    9.0                             7.0                             11.0

Note that the results of the confidence intervals could vary, because they are estimated with a probabilistic resampling technique.

Release files for lifetime-value 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lifetime-value 0.0.6
File Size Uploaded
lifetime-value-0.0.6.tar.gz 4.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lifetime-value 0.0.6
File Interpreter ABI Platform
lifetime_value-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 8.9 kB

Release files / lifetime-value-0.0.6.tar.gz

Download URL lifetime-value-0.0.6.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
175d245da876b653b4e5629bebcc1f52bf26ad941065f681c3fd4ca861c90308
BLAKE2b-256 checksum
How to use checksums
8535b42dbd2e13aac0d3e5d9c51659022f031870b8cf85da432a70138c4434bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.4

Release files / lifetime_value-0.0.6-py3-none-any.whl

Download URL lifetime_value-0.0.6-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7c1e835a23522a1035408e3872554666276bca21821dfa2eaecd5ee66c260de4
BLAKE2b-256 checksum
How to use checksums
464a01be9ccac7aefa6553c1bd79d045713ca78b7b2bcc50a263d5832d8421cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.4

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page