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.from_subjects_and_events_dataframe(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.5.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for lifetime_value-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd2a15f6d9c87a1b15fe270dced4ff18396230ded476e95863c6bef443959c02 |
|
MD5 | 552ed149f7ebd8aba39f43ab57fa2e26 |
|
BLAKE2b-256 | dcaa4ece73b8f8e210ca038f212bf64deffc706d48d8d69a654caeda60e3e616 |