Search⌘ K
AI Features

Solution Review: Create k-means Model

Explore how to create a K-Means clustering model with three clusters using PyCaret's create_model function. Learn to assign cluster labels to your dataset and view sample results, helping you evaluate the clustering outcome effectively.

We'll cover the following...

Solution

Python 3.5
# Create K-Means model with 3 clusters and assign it to model variable.
model = create_model('kmeans', num_clusters = 3)
# Assign cluster labels to the dataset and assign result to clusters variable.
clusters = assign_model(model)
# Print the first 10 instances of the resulting dataset.
clusters.head(10)

Explanation

  • Line 3: We create a KK ...