Launch the interactive walkthrough to discover each component, including the 3D Q-Sphere Lab & Python in Colab.
Survey the three foundational pillars of ML: Supervised Learning, Unsupervised Learning, and Reinforcement Learning.
Input + Label -> Loss Calculation -> Gradient Descent -> Predictive Model.
Input Only -> Distance/Density Calculation -> Centroids/Embeddings -> Structural Clustering.
State -> Action -> Environment Transition -> Reward Signal -> Policy Optimization.
Problem: Classifying incoming emails.
Solution: Model trained on 100,000 human-marked "Spam" vs "Not Spam" emails.
Problem: Group 1 million shoppers without pre-existing labels.
Solution: K-Means clustering segments customers by purchasing velocity and basket size.
Problem: Mastering the ancient board game Go.
Solution: Deep RL agent played millions of self-play games to surpass all human champions.
Interactive activity component
See a supervised classifier and an unsupervised clusterer side-by-side on the same 2D data.
For Google Colab or Jupyter notebooks, run this shell command to install the required dependencies:
!pip install scikit-learn numpy1 from sklearn.neighbors import KNeighborsClassifier 2 from sklearn.cluster import KMeans 3 import numpy as np
from sklearn.neighbors import KNeighborsClassifier → Supervised classifier
from sklearn.cluster import KMeans → Unsupervised clusterer
import numpy as np → Array processing
1 X = np.array([[1, 2], [1, 4], [2, 2], [8, 7], [9, 8], [8, 9]]) 2 y = [0, 0, 0, 1, 1, 1] # Labels for supervised 3 4 # 1. Supervised Learning (Uses both X and y): 5 knn = KNeighborsClassifier(n_neighbors=1).fit(X, y) 6 print("Supervised Prediction for [2,3]:", knn.predict([[2, 3]])) 7 8 # 2. Unsupervised Learning (Uses ONLY X! No labels given!): 9 kmeans = KMeans(n_clusters=2, random_state=42).fit(X) 10 print("Unsupervised Cluster Assignments:", kmeans.labels_)
X = np.array([[1, 2], [1, 4], [2, 2], [8, 7], [9, 8], [8, 9]])
6 data points in 2D
y = [0, 0, 0, 1, 1, 1] # Labels for supervised
Class labels
# 1. Supervised Learning (Uses both X and y):
KNN model
knn = KNeighborsClassifier(n_neighbors=1).fit(X, y)
Fit with labels
print("Supervised Prediction for [2,3]:", knn.predict([[2, 3]]))
Predict label
# 2. Unsupervised Learning (Uses ONLY X! No labels given!):
K-Means model
kmeans = KMeans(n_clusters=2, random_state=42).fit(X)
Find 2 natural clusters
print("Unsupervised Cluster Assignments:", kmeans.labels_)
Display discovered clusters
Click "Copy for Colab", open Google Colab, paste into a single cell, and run.
1 # ========================================================= 2 # Comparing Supervised vs Unsupervised in Code 3 # Prepared for Google Colab (Run with Shift + Enter) 4 # ========================================================= 5 6 # Step 1: Install required packages 7 !pip install scikit-learn numpy 8 9 # Step 2: Import libraries 10 from sklearn.neighbors import KNeighborsClassifier 11 from sklearn.cluster import KMeans 12 import numpy as np 13 14 # Step 3: Run Demonstration 15 X = np.array([[1, 2], [1, 4], [2, 2], [8, 7], [9, 8], [8, 9]]) 16 y = [0, 0, 0, 1, 1, 1] # Labels for supervised 17 18 # 1. Supervised Learning (Uses both X and y): 19 knn = KNeighborsClassifier(n_neighbors=1).fit(X, y) 20 print("Supervised Prediction for [2,3]:", knn.predict([[2, 3]])) 21 22 # 2. Unsupervised Learning (Uses ONLY X! No labels given!): 23 kmeans = KMeans(n_clusters=2, random_state=42).fit(X) 24 print("Unsupervised Cluster Assignments:", kmeans.labels_)
KNN learns boundary separating class 0 from class 1.
K-Means groups the points into 2 geographic clusters purely by coordinate proximity.
6 points with two distinct geometric clusters
Supervised Prediction for [2,3]: [0] Unsupervised Cluster Assignments: [1 1 1 0 0 0]
The unsupervised algorithm automatically discovered the two natural clusters without ever being told what the classes were!
Data, prediction, and the bridge to modern artificial intelligence.
Test your understanding with these questions. Remember, this is for learning, not examination!