Complete the code to import the function for calculating the silhouette score.
from sklearn.metrics import [1]
The silhouette_score function is used to evaluate clustering quality by measuring how similar an object is to its own cluster compared to other clusters.
Complete the code to calculate the silhouette score for data X with labels y_pred.
score = silhouette_score([1], y_pred)The silhouette score requires the original data points X and the predicted cluster labels y_pred to compute the score.
Fix the error in the code to compute the adjusted Rand index between true labels and predicted labels.
from sklearn.metrics import adjusted_rand_score ari = adjusted_rand_score([1], y_pred)
The adjusted Rand index compares the true labels labels_true with the predicted labels y_pred. Passing the data X or predicted labels twice is incorrect.
Fill both blanks to create a dictionary of cluster sizes for each cluster label in y_pred.
cluster_sizes = {label: y_pred.count([1]) for label in [2]We count how many times each label appears in y_pred. The dictionary keys are the unique labels, which we get using set(y_pred).
Fill all three blanks to compute the completeness score between true labels and predicted labels.
from sklearn.metrics import [1] score = [1]([2], [3])
The completeness_score function measures how well all members of a given class are assigned to the same cluster. It takes true labels and predicted labels as arguments.