Začněte nyníZačněte zdarma

K-means clustering

A very commonly used clustering algorithm is K-means clustering. For fraud detection, K-means clustering is straightforward to implement and relatively powerful in predicting suspicious cases. It is a good algorithm to start with when working on fraud detection problems. However, fraud data is oftentimes very large, especially when you are working with transaction data. MiniBatch K-means is an efficient way to implement K-means on a large dataset, which you will use in this exercise.

The scaled data from the previous exercise, X_scaled is available. Let's give it a try.

Toto cvičení je součástí kurzu

Fraud Detection in Python

Zobrazit kurz

Pokyny k cvičení

  • Import MiniBatchKMeans from sklearn.
  • Initialize the minibatch kmeans model with 8 clusters.
  • Fit the model to your scaled data.

Interaktivní cvičení na vyzkoušení si v praxi

Vyzkoušejte si toto cvičení dokončením tohoto ukázkového kódu.

# Import MiniBatchKmeans 
from sklearn.cluster import ____

# Define the model 
kmeans = ____(n_clusters=____, random_state=0)

# Fit the model to the scaled data
kmeans.____(____)
Upravit a spustit kód