✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Consider the following code snippet for a nearest centroid classifier:
from sklearn.datasets import load_digitsfrom sklearn.model_selection import train_test_splitfrom sklearn.metrics import accuracy_scoreimport numpy as np
digits = load_digits()X, y = digits.data, digits.targetX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
centroids, classes = compute_centroids(________) # Fill the missing termy_pred = predict_centroids(centroids, classes, X_test)
print("Accuracy:", accuracy_score(y_test, y_pred))
What should replace the blank ________ to correctly compute the centroids?