0
0
SciPydata~30 mins

Cluster evaluation metrics in SciPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Cluster Evaluation Metrics
📖 Scenario: You have grouped customers into clusters based on their shopping behavior. Now, you want to check how good these clusters are by comparing them to known customer groups.
🎯 Goal: Build a small program to calculate cluster evaluation metrics using sklearn. You will create true labels and predicted cluster labels, then compute the Adjusted Rand Index and Normalized Mutual Information scores.
📋 What You'll Learn
Create two lists: true_labels and predicted_labels with exact values
Import adjusted_rand_score and normalized_mutual_info_score from sklearn.metrics
Calculate ari_score using adjusted_rand_score(true_labels, predicted_labels)
Calculate nmi_score using normalized_mutual_info_score(true_labels, predicted_labels)
Print both scores with descriptive text
💡 Why This Matters
🌍 Real World
Cluster evaluation metrics help businesses check if their customer groups or product categories are meaningful and useful.
💼 Career
Data scientists and analysts use these metrics to validate clustering results and improve machine learning models.
Progress0 / 4 steps
1
Create true and predicted cluster labels
Create a list called true_labels with values [0, 0, 1, 1, 2, 2] and a list called predicted_labels with values [0, 0, 2, 1, 2, 2].
SciPy
Need a hint?

Use square brackets to create lists with the exact numbers given.

2
Import cluster evaluation functions
Import adjusted_rand_score and normalized_mutual_info_score from sklearn.metrics.
SciPy
Need a hint?

Use from sklearn.metrics import adjusted_rand_score, normalized_mutual_info_score.

3
Calculate ARI and NMI scores
Calculate ari_score by calling adjusted_rand_score(true_labels, predicted_labels) and calculate nmi_score by calling normalized_mutual_info_score(true_labels, predicted_labels).
SciPy
Need a hint?

Call the functions with the two lists as arguments and save results in ari_score and nmi_score.

4
Print the cluster evaluation scores
Print the text "Adjusted Rand Index:" followed by ari_score and print the text "Normalized Mutual Information:" followed by nmi_score.
SciPy
Need a hint?

Use two print statements with the exact text and variables.