Skip to content

Instantly share code, notes, and snippets.

@dyerrington
Created November 13, 2017 08:40
Show Gist options
  • Save dyerrington/35ec6dd854226e9c8d6d1877626aacce to your computer and use it in GitHub Desktop.
Save dyerrington/35ec6dd854226e9c8d6d1877626aacce to your computer and use it in GitHub Desktop.
Extremely terse example using out of context lastfm artist dataset. If you're interested in the full example, I will update this if you message me directly or comment here.
from sklearn.neighbors import NearestNeighbors
nn = NearestNeighbors(n_neighbors=150, radius=10)
model = nn.fit(artist_genre)
A = model.radius_neighbors_graph(artist_genre)
artist_neighbors = pd.DataFrame(A.toarray(), columns=artist_sim.index, index=artist_sim.index)
artist_neighbors['2Pac'].sort_values(ascending=False).head(150)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment