Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Summary transaction data round to whole periods not float #100

Closed
aprotopopov opened this issue May 31, 2017 · 1 comment
Closed

Summary transaction data round to whole periods not float #100

aprotopopov opened this issue May 31, 2017 · 1 comment

Comments

@aprotopopov
Copy link
Collaborator

Tried to get RFM matrix from raw CDNOW transactions sample but without success with summary_data_from_transaction_data due to to_freq rounding to whole digits. Do you have idea how to improve that?
I came with hucky solution to set freq='D' and then divide recency and T on 7 to get appropriate numbers in function summary_data_from_transaction_data but it doesn't seem a good way to solve problems like that.

from lifetimes.datasets import load_transaction_data, load_cdnow_summary, load_dataset
from lifetimes.utils import summary_data_from_transaction_data

df_cdnow_summary = load_cdnow_summary()

transactions = load_dataset('CDNOW_sample.txt', header=None, sep='\s+')
transactions.columns = ['id_total', 'id_sample', 'date', 'num_cd_purc', 'total_value']
summary_trans = summary_data_from_transaction_data(transactions, 'id_sample', 'date', datetime_format='%Y%m%d', 
                                   observation_period_end='19970930', freq='W')

df_cdnow_summary.head()
"""
   ID  frequency  recency      T
0   1          2    30.43  38.86
1   2          1     1.71  38.86
2   3          0     0.00  38.86
3   4          0     0.00  38.86
4   5          0     0.00  38.86
"""
summary_trans.head()
"""
           frequency  recency     T
id_sample                          
1                2.0     30.0  39.0
2                1.0      2.0  39.0
3                0.0      0.0  39.0
4                0.0      0.0  39.0
5                0.0      0.0  39.0
"""
@aprotopopov
Copy link
Collaborator Author

Functionality for that is added in PR #181

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant