Lifetime value function over time.
Project description
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 pandas as pd
import lifetime_value as ltv
df_subjects = pd.DataFrame({
'subject_id': ['a', 'b', 'c'],
'lifetime': [6, 6, 4],
})
df_events = pd.DataFrame({
'subject_id': ['a', 'a', 'b', 'c', 'c', 'a'],
'time': [3, 1, 5, 1, 4, 3],
'value': [12.3, 0.5, 1.5, 3.3, 34.3, 1.2]
})
df_result = ltv.lifetime_value(df_subjects, df_events, confidence_level=0.8)
print(df_result)
Will return:
time value confidence_interval_left_bound confidence_interval_right_bound
0 0 0.000000 0.000000 0.000000
1 1 1.266667 0.166667 2.366667
2 2 1.266667 0.166667 2.366667
3 3 5.766667 1.100000 10.433333
4 4 17.200000 4.666667 29.733333
Note that the results of the confidence intervals could vary, because they are estimated with a probabilistic resampling technique.
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
lifetime-value-0.0.4.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for lifetime_value-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ca9cbecdbb8c60e1cf4ca0832c1c41609eb59829be2a677605150e0b4ca1f23 |
|
MD5 | 8f29f875f16ab363db9711f85dba6657 |
|
BLAKE2b-256 | 9f1e73da8a676f55ffc6e8395c40a5855cea6bf0426646536b907d39346f9efa |