Created
November 16, 2020 04:50
-
-
Save tanpengshi/0ee4cfee1b463e51d903ac46d672aec9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group = df.groupby(['user_id','product_id'])['user_score','user_purchase'].sum().reset_index() | |
group['user_purchase'] = group['user_purchase'].apply(lambda x: 1 if x>1 else x) | |
group['user_score'] = group['user_score'].apply(lambda x: 100 if x>100 else x) | |
std = MinMaxScaler(feature_range=(0.025, 1)) | |
std.fit(group['user_score'].values.reshape(-1,1)) | |
group['interaction_score'] = std.transform(group['user_score'].values.reshape(-1,1)) | |
group = group.merge(df[['product_id','category_code','brand','price','price_category']].drop_duplicates('product_id'),on=['product_id']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment