Supervised vs Unsupervised Learning
The two main paradigms of machine learning — labeled vs unlabeled data
Free tier: read the explanation here. Upgrade to Pro for Drills, Speed challenges & Mastery badges.
UpgradeKnowledge Debt detected
You can study this freely — but your score may plateau if these foundations have gaps. The Mastery badge requires them to be solid.
Explanation
Supervised Learning — learn from labeled examples (input + correct output). - Training data: (X, y) pairs — features and known labels - Goal: predict labels for new inputs - Examples: spam detection, house price prediction, image classification
Unsupervised Learning — find patterns in unlabeled data. - Training data: X only — no labels - Goal: discover structure (clusters, patterns, anomalies) - Examples: customer segmentation, anomaly detection, topic modeling
Common algorithms:
| Type | Algorithms | |------|-----------| | Supervised — Classification | Logistic Regression, Decision Trees, Random Forest, SVM, Neural Networks | | Supervised — Regression | Linear Regression, Ridge, LASSO, Gradient Boosting | | Unsupervised — Clustering | K-Means, DBSCAN, Hierarchical Clustering | | Unsupervised — Dimensionality Reduction | PCA, t-SNE, UMAP |
Semi-supervised — small labeled dataset + large unlabeled dataset (common in real world). Reinforcement Learning — agent learns by reward signals (games, robotics).
Examples
K-Means clustering (unsupervised)
Note: fit(X) has no y — there are no labels in unsupervised learning
from sklearn.cluster import KMeans
import numpy as np
# No labels — just features
X = np.array([[1,2],[1,4],[1,0],[10,2],[10,4],[10,0]])
kmeans = KMeans(n_clusters=2, random_state=42)
kmeans.fit(X) # no y parameter!
print(kmeans.labels_) # [0,0,0,1,1,1] or [1,1,1,0,0,0]
print("Cluster centers:", kmeans.cluster_centers_)How well did you understand this?
Next in Machine Learning Basics
Classification vs Regression