Question: pandas/ scikit-learn I need to cluster using scikit-learn by instantiating a KMeans object and passing it the number of clusters I want to fit and
pandas/ scikit-learn
I need to cluster using scikit-learn by instantiating a KMeans object and passing it the number of clusters I want to fit and create a confusion matrix
Confusion Matrices
Once we cluster a set of features, we can check whether most of the 0's ended up in a single cluster, and so on for all the true labels. We'll do this by making a confusion matrix: this is a d x d matrix M where M[i,j] is the number of datapoints whose true label is i got assigned to cluster center j.
Complete the following function, which takes a set of features and labels, performs k-means clustering with k=10 (this part does not make use of the labels), then and builds a confusion matrix relating cluster centers to true labels.
def makes_confusion(features, labels):
""" Cluster features (n, d) and generate a confusion matrix with the ground truth labels. features is (n, d); labels is (n,). Returns a (d, d) confusion matrix."""
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
