開始使用免費開始

視覺化 itemset 的 support

一家新創串流內容公司找你做顧問。他們想把授權費壓低,因此計畫打造一個精簡的電影片庫,鎖定同一受眾的喜好。雖然內容選擇會比產業中的大玩家少,但他們也能提供較低的訂閱費。

你決定使用 MovieLens 資料與 heatmap 來完成這個專案。使用以 support 為基礎的簡單 heatmap,可以幫你找出與其他片名一起出現 support 較高的個別片名。已完成 one-hot 編碼的資料可在 DataFrame onehot 中取得。此外,pandas 已以 pd 匯入,seabornsns 匯入,apriori()association_rules() 也都已匯入。

本練習屬於課程

Python 的 Market Basket Analysis

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Compute frequent itemsets using a minimum support of 0.07
frequent_itemsets = apriori(onehot, min_support = ____, 
                            use_colnames = True, max_len = 2)

# Compute the association rules
rules = association_rules(____, metric = 'support', 
                          min_threshold = 0.0)
編輯並執行程式碼