Skip to content

Instantly share code, notes, and snippets.

@ychennay
Created May 23, 2019 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ychennay/5a1991caf9513a32ac2d4fa4c99740ff to your computer and use it in GitHub Desktop.
Save ychennay/5a1991caf9513a32ac2d4fa4c99740ff to your computer and use it in GitHub Desktop.
from sklearn.manifold import SpectralEmbedding
import seaborn as sns
for threshold in range(1,8):
nonzeros = (conversions_df["Approved_Conversion"] >= threshold)
sizes = conversions_df["Spent"].values ** 2 + 10
mds = SpectralEmbedding(n_components=2, affinity="precomputed")
reduced_dimensions = mds.fit_transform(proximity_matrix)
sns.scatterplot(x=reduced_dimensions[:,0], y=reduced_dimensions[:, 1],
hue=nonzeros, alpha=0.5, legend=False, size=sizes)
plt.title(f"Spectral Embedding Visualization of \n Random Forest Proximity Matrix ({threshold} or More Conversions)")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment