Aantal clusters kiezen

Klantsegmentatie in Python

Karolis Urbonas

Head of Data Science, Amazon

Methoden

  • Visuele methode: elbow-criterium
  • Wiskundige methode: silhouettecoëfficiënt
  • Experimenteren en interpreteren
Klantsegmentatie in Python

Elbow-criterium

  • Plot het aantal clusters tegen de within-cluster som van kwadratische fouten (SSE) - som van kwadratische afstanden van elk datapunt tot het clustercentrum
  • Zoek de “elbow” in de plot
  • Elbow: punt met een “optimaal” aantal clusters
Klantsegmentatie in Python

Elbow-criterium

# Import key libraries
from sklearn.cluster import KMeans
import seaborn as sns
from matplotlib import pyplot as plt

# Fit KMeans and calculate SSE for each *k* sse = {} for k in range(1, 11): kmeans = KMeans(n_clusters=k, random_state=1) kmeans.fit(data_normalized) sse[k] = kmeans.inertia_ # sum of squared distances to closest cluster center
# Plot SSE for each *k* plt.title('The Elbow Method') plt.xlabel('k'); plt.ylabel('SSE') sns.pointplot(x=list(sse.keys()), y=list(sse.values())) plt.show()
Klantsegmentatie in Python

Elbow-criterium

De elbow-grafiek:

Klantsegmentatie in Python

Elbow-criterium

De elbow-grafiek:

Klantsegmentatie in Python

Elbow-criterium gebruiken

  • Kies het punt op de elbow of het volgende punt
  • Gebruik als richtlijn en test meerdere opties
  • Elbow-plot gemaakt op datamart_rfm

Klantsegmentatie in Python

Experimentele aanpak - segmenten analyseren

  • Bouw clustering rond de elbow-oplossing
  • Analyseer eigenschappen: gemiddelde RFM-waarden
  • Vergelijk en kies wat zakelijk het meest logisch is
Klantsegmentatie in Python

Experimentele aanpak - segmenten analyseren

  • Vorige 2-clusteroplossing
  • 3-clusteroplossing op dezelfde genormaliseerde RFM-dataset
Klantsegmentatie in Python

Laten we het optimale aantal clusters vinden!

Klantsegmentatie in Python

Preparing Video For Download...