Unsupervised and reinforcement learning

11 min read

Unsupervised learning: finding structure without labels

Most data in the world has no labels. Unsupervised methods find patterns anyway.

  • Clustering groups similar items. k-means picks k center points, assigns each item to its nearest center, moves each center to the middle of its group, and repeats until stable. Uses: customer segments, grouping news stories, finding similar documents.
  • Dimensionality reduction compresses many features into a few that capture most of the variation. PCA (principal component analysis) is the classic method. Uses: visualization, noise removal, speeding up other models.
  • Anomaly detection learns what "normal" looks like and flags what doesn't fit: fraud, equipment faults, network intrusions.

Self-supervised learning is the trick behind modern foundation models. The data provides its own labels: hide a word and predict it, or predict the next word from the ones before. No human labeling is needed, so models can learn from trillions of words. Large language models are trained this way.

Reinforcement learning: learning by doing

In reinforcement learning (RL), an agent takes actions in an environment, observes the new state, and receives a reward (or penalty). Its goal is to learn a policy, a strategy for choosing actions, that maximizes total reward over time.

  • Q-learning estimates the value of taking each action in each state, updating its estimates from experience.
  • Explore vs exploit: should the agent try something new (which might be better) or repeat what has worked? A common approach, epsilon-greedy, explores randomly a small fraction of the time.
  • Delayed reward: in chess, the reward comes only at the end. RL must work out which earlier moves deserve credit.

Where RL shows up

  • Game-playing (AlphaGo, Atari agents), robotics, data-center cooling, recommendation systems.
  • Training language models: reinforcement learning from human feedback (RLHF) teaches chatbots to be helpful and avoid harm, and RL on problems with checkable answers (math, code) is how "reasoning" models learn to think step by step. You'll see both in Module 5.

A warning: reward hacking

RL agents optimize exactly what they're rewarded for, which may not be what you meant. A boat-racing agent once learned to spin in circles collecting points instead of finishing the race. Specifying the right objective is one of the central problems in AI safety.

Check your understanding

Check 1 of 2Module 3 · Machine learning

Training a model to predict the next word in billions of web pages, with no human labels, is called:

Check 2 of 2Module 3 · Machine learning

An RL agent finds a loophole to collect reward without doing the intended task. This is:

Answer the checks, then mark this lesson complete
Completion and scores are saved in this browser.