Unsupervised Learning Flashcards

(20 cards)

1
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is unsupervised learning?

A

A type of machine learning where the model learns patterns from data without labeled outputs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is clustering?

A

Grouping similar data points together based on feature similarity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which library provides KMeans in Python?

A

from sklearn.cluster import KMeans

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you create a KMeans model with 3 clusters?

A

KMeans(n_clusters=3)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you fit and predict cluster labels in one step?

A

kmeans.fit_predict(X)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you access cluster labels after prediction?

A

Use the output of fit_predict(), or kmeans.labels_

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you view the coordinates of cluster centers?

A

kmeans.cluster_centers_

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is inertia_ in KMeans?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the Elbow Method?

A

A technique to find the optimal number of clusters by plotting inertia vs. number of clusters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you scale features before clustering?

A

Use MinMaxScaler or StandardScaler from sklearn.preprocessing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you plot an elbow curve?

A

Loop over k, store km.inertia_, then plot SSE vs k using matplotlib.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why do we use feature scaling before clustering?

A

To ensure all features contribute equally to distance calculations.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you visualize clusters in 2D using matplotlib?

A

Use plt.scatter() for each cluster and plot centroids with ‘x’ markers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you assign cluster labels back to the DataFrame?

A

df[‘cluster’] = kmeans.fit_predict(X)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you print the unique cluster labels in a DataFrame?

A

df[‘cluster’].unique()

17
Q

How do you check the number of records in each cluster?

A

df[‘cluster’].value_counts()

18
Q

How do you train a clustering model?

A

Create the KMeans model, then call fit() or fit_predict() on the data.

19
Q

How do you remember how to train KMeans?

A

Think ‘Create → Fit → Predict’ (C → F → P) using fit_predict()

20
Q

How do you create an elbow plot to choose optimal k?

A

Loop through k-values, fit model, record inertia, then plot.