Recommend musical artists part II
Suppose you were a big fan of Bruce Springsteen - which other musical artists might you like? Use your NMF features from the previous exercise and the cosine similarity to find similar musical artists. A solution to the previous exercise has been run, so norm_features is an array containing the normalized NMF features as rows. The names of the musical artists are available as the list artist_names.
Deze oefening maakt deel uit van de cursus
Unsupervised Learning in Python
Oefeninstructies
- Import
pandasaspd. - Create a DataFrame
dffromnorm_features, usingartist_namesas an index. - Use the
.loc[]accessor ofdfto select the row of'Bruce Springsteen'. Assign the result toartist. - Apply the
.dot()method ofdftoartistto calculate the dot product of every row withartist. Save the result assimilarities. - Print the result of the
.nlargest()method ofsimilaritiesto display the artists most similar to'Bruce Springsteen'.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Import pandas
____
# Create a DataFrame: df
df = ____
# Select row of 'Bruce Springsteen': artist
artist = df.loc[____]
# Compute cosine similarities: similarities
similarities = ____
# Display those with highest cosine similarity
____