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 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.
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.6.tar.gz
(4.4 kB
view details)
Built Distribution
File details
Details for the file lifetime-value-0.0.6.tar.gz
.
File metadata
- Download URL: lifetime-value-0.0.6.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 175d245da876b653b4e5629bebcc1f52bf26ad941065f681c3fd4ca861c90308 |
|
MD5 | 5a63e4ed10eb54c557de9133724163a0 |
|
BLAKE2b-256 | 8535b42dbd2e13aac0d3e5d9c51659022f031870b8cf85da432a70138c4434bc |
File details
Details for the file lifetime_value-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: lifetime_value-0.0.6-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c1e835a23522a1035408e3872554666276bca21821dfa2eaecd5ee66c260de4 |
|
MD5 | f4cf420eea83de147abd212c08e187bb |
|
BLAKE2b-256 | 464a01be9ccac7aefa6553c1bd79d045713ca78b7b2bcc50a263d5832d8421cd |