Created
November 16, 2020 12:50
-
-
Save tanpengshi/983dbfb3cc8cc4bd69bdc9b82fde28d4 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
content_matrix = pd.DataFrame(content_matrix,columns=sorted(X_train['product_id'].unique()),index=sorted(X_train['user_id'].unique())) | |
content_df = content_matrix.stack().reset_index() | |
content_df = content_df.rename(columns={'level_0':'user_id','level_1':'product_id',0:'predicted_interaction'}) | |
X_valid = X_valid.merge(content_df,on=['user_id','product_id']) | |
X_valid['predicted_purchase'] = X_valid['predicted_interaction'].apply(lambda x:1 if x>=0.5 else 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment