IniziaInizia gratis

Run k-means

You will now build a 3 clusters with k-means clustering. We have loaded the pre-processed RFM dataset as datamart_normalized. We have also loaded the pandas library as pd.

You can explore the dataset in the console to get familiar with it.

Questo esercizio fa parte del corso

Customer Segmentation in Python

Visualizza il corso

Istruzioni dell'esercizio

  • Import KMeans from the scikit-learn library.
  • Initialize KMeans with 3 clusters and random state 1.
  • Fit k-means clustering on the normalized data set.
  • Extract cluster labels and store them as cluster_labels.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Import KMeans 
from ____.____ import ____

# Initialize KMeans
kmeans = ____(____=3, ____=1) 

# Fit k-means clustering on the normalized data set
____.____(datamart_normalized)

# Extract cluster labels
cluster_labels = ____.____
Modifica ed esegui il codice