MSD の要約統計
Million Songs の Echo Nest Taste Profile サブセットに慣れていきましょう。このコースでは便宜上、Million Songs データセットまたは msd と呼びます。ユーザー数と楽曲数を求めましょう。また、このサブセットで再生回数が最も多い曲も確認しましょう。
この演習はコースの一部です
PySpark で作る Recommendation Engines
演習の手順
.show()メソッドを使って、データの中身を確認しましょう。- 一意な
userIdの件数を数えるコードを完成させてください。userId列を選択し、.distinct()と.count()を呼び出します。 - 次に
songIdに対して同じことを行い、一意なsongIdの件数を数えましょう。songId列を選択し、.distinct()と.count()を呼び出します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Look at the data
msd.____()
# Count the number of distinct userIds
user_count = msd.select("____").____().count()
print("Number of users: ", user_count)
# Count the number of distinct songIds
song_count = msd.select("____").____().count()
print("Number of songs: ", song_count)