Exercise

Recommend musical artists part I

In this exercise and the next, you'll use what you've learned about NMF to recommend popular music artists! You are given a sparse array artists whose rows correspond to artists and whose columns correspond to users. The entries give the number of times each artist was listened to by each user.

In this exercise, build a pipeline and transform the array into normalized NMF features. The first step in the pipeline, MaxAbsScaler, transforms the data so that all users have the same influence on the model, regardless of how many different artists they've listened to. In the next exercise, you'll use the resulting normalized NMF features for recommendation!

Instructions

100 XP
  • Import:
    • NMF from sklearn.decomposition.
    • Normalizer and MaxAbsScaler from sklearn.preprocessing.
    • make_pipeline from sklearn.pipeline.
  • Create an instance of MaxAbsScaler called scaler.
  • Create an NMF instance with 20 components called nmf.
  • Create an instance of Normalizer called normalizer.
  • Create a pipeline called pipeline that chains together scaler, nmf, and normalizer.
  • Apply the .fit_transform() method of pipeline to artists. Assign the result to norm_features.