ComenzarEmpieza gratis

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 ejercicio forma parte del curso

Fraud Detection in Python

Ver curso

Instrucciones del ejercicio

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

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Import MiniBatchKmeans 
from sklearn.cluster import ____

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

# Fit the model to the scaled data
kmeans.____(____)
Editar y ejecutar código