Machine Learning Algorithm Quizzes

K-means Clustering

Question 1

K-Means is an example of which type of machine learning?

Question 2

Which line of code correctly imports the K-Means model from scikit-learn?

Question 3

The most important hyperparameter that you must specify before running the K-Means algorithm is __________, which defines the number of clusters to create.

Your answer here.

Question 4

Why is feature scaling (e.g., using StandardScaler) a crucial preprocessing step for the K-Means algorithm?

Question 5

Select all the steps that are part of the iterative K-Means algorithm.

Question 6

A common technique for finding the optimal value of 'K' is the __________, which involves plotting the model's inertia for a range of K values.

Your answer here.

Question 7

In scikit-learn's KMeans model, what does the .inertia_ attribute represent after the model has been fitted?

Question 8

What are some of the known limitations of the K-Means algorithm?

Question 9

After fitting a KMeans model named model on your data, how do you retrieve the cluster assignments (labels) for each of your data points?

End of Quiz

Your final score is: 0 / 0

List of Questions

Question 1: K-Means is an example of which type of machine learning?

Answers: Unsupervised Learning.

Question 2: Which line of code correctly imports the K-Means model from scikit-learn?

Answers: from sklearn.cluster import KMeans.

Question 3: Why is feature scaling (e.g., using `StandardScaler`) a crucial preprocessing step for the K-Means algorithm?

Answers: It is based on calculating distances, and features with larger scales can disproportionately influence the result..

Question 4: Select all the steps that are part of the iterative K-Means algorithm.

Answers: Initialize K cluster centroids randomly., Assign each data point to the cluster of its nearest centroid., Recalculate the position of each centroid as the mean of the points assigned to it..

Question 5: In scikit-learn's `KMeans` model, what does the `.inertia_` attribute represent after the model has been fitted?

Answers: The sum of squared distances of samples to their closest cluster center..

Question 6: What are some of the known limitations of the K-Means algorithm?

Answers: It is sensitive to the initial placement of centroids., It struggles with clusters that are not spherical or are of different densities., The number of clusters, K, must be specified in advance..

Question 7: After fitting a `KMeans` model named `model` on your data, how do you retrieve the cluster assignments (labels) for each of your data points?

Answers: model.labels_.