K-means 分群
最常用的分群演算法之一是 K-means 分群。在詐欺偵測中,K-means 分群容易實作,且在預測可疑案例時相當有力,是處理詐欺偵測問題時很好的起點。不過,詐欺相關的資料往往非常龐大,特別是交易資料。MiniBatch K-means 提供在大型資料集上實作 K-means 的高效率方式,你將在本練習中使用它。
先前練習已經產生過縮放後的資料 X_scaled。來試試看吧。
本練習屬於課程
Fraud Detection in Python
練習說明
- 從
sklearn匯入MiniBatchKMeans。 - 以 8 個群集初始化 minibatch kmeans 模型。
- 將模型擬合到縮放後的資料上。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import MiniBatchKmeans
from sklearn.cluster import ____
# Define the model
kmeans = ____(n_clusters=____, random_state=0)
# Fit the model to the scaled data
kmeans.____(____)