Created
March 15, 2020 16:37
-
-
Save ikatsov/0fd1b9f42cb4ed9e5d0f81b7394ef229 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
from sklearn.preprocessing import MinMaxScaler | |
mm_scale = MinMaxScaler() | |
# feature_df is the dataframe with customer features | |
feature_df_scale = pd.DataFrame(mm_scale.fit_transform(feature_df), | |
columns=feature_df.columns, | |
index=feature_df.index.values) | |
tsne_doc_features = TSNE(n_components=2, verbose=1, perplexity=30, n_iter=500) | |
tsne_features_doc = tsne_doc_features.fit_transform(feature_df_scale.values) | |
tsne_doc_features = pd.DataFrame({'user_id':feature_df.index.values}) | |
tsne_doc_features['tsne-2d-one'] = tsne_features_doc[:,0] | |
tsne_doc_features['tsne-2d-two'] = tsne_features_doc[:,1] | |
plt.figure(figsize=(16, 10)) | |
sns.scatterplot( | |
x="tsne-2d-one", y="tsne-2d-two", | |
data=tsne_doc_features, | |
legend="full", | |
alpha=0.3 | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment