Chapter 24 of 30
Keep learning and build your Data Science skills.
Unsupervised Learning
Learn how models discover patterns in data without target labels.
Theory
Unsupervised Learning works with data without predefined target labels.
The model attempts to discover structure or patterns.
Common techniques include:
• Clustering
• Dimensionality Reduction
• Association Analysis
K-Means is a popular clustering algorithm.
Example
from sklearn.cluster import KMeans
X = [
[1, 2],
[1, 3],
[8, 8],
[9, 9]
]
model = KMeans(
n_clusters=2,
random_state=42
)
model.fit(X)
print(model.labels_)Output
The data points are assigned to discovered clusters.
Practice
Apply K-Means clustering to a small dataset.
Interview Questions
1
What is unsupervised learning?
2
What is clustering?
3
What is dimensionality reduction?
Quick Quiz
Which option best describes this chapter?
A.Unlabeled data
B.Only labeled data
C.Only test labels
D.No input data