ComeçarComece de graça

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.

Este exercício faz parte do curso

Fraud Detection in Python

Ver curso

Instruções do exercício

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

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Import MiniBatchKmeans 
from sklearn.cluster import ____

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

# Fit the model to the scaled data
kmeans.____(____)
Editar e executar o código