打造你的第一個電影推薦
既然你已經找出最常一起出現的電影配對,就能開始做出第一個推薦!
即使你沒有任何關於觀看者的資訊,甚至不清楚電影的細節,仍然可以藉由觀察同一群人會一起觀看哪些電影,提出有價值的推薦。
在這個練習中,你會檢視那些常與 Thor 被同一批人一起觀看的電影,接著用這些資料替剛看完這部電影的人給出推薦。
你在上一個單元建立的 DataFrame combination_counts_df 已幫你載入,其中包含電影被一同觀看的次數統計。
本練習屬於課程
用 Python 建立推薦引擎
練習說明
- 依據
size欄位,將combination_counts_df物件由大到小排序。 - 透過子設定排序後的
combination_counts_df,篩出movie_a為Thor的列,取得新的電影頻率,指定為thor_df,並將結果繪圖。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
import matplotlib.pyplot as plt
# Sort the counts from highest to lowest
combination_counts_df.____('size', ascending=____, inplace=____)
# Find the movies most frequently watched by people who watched Thor
thor_df = ____[____['movie_a'] ____ 'Thor']
# Plot the results
thor_df.plot.bar(x="movie_b")
plt.show()