The Four Types of Machine Learning
Reinforcement Learning
3 min read
Learning by doing, not by studying examples
Reinforcement learning is a type of machine learning in which algorithms are trained to learn from the environment by performing actions and receiving either rewards or penalties as feedback. There's no dataset of correct answers to study in advance — there's only trial, error, and consequence.
If the program finds the correct solution, the interpreter rewards the algorithm. If the outcome is incorrect, the algorithm is penalized for the incorrect prediction — and it must reiterate until it finds a better result.
The core loop
Reinforcement learning centers on two roles constantly interacting:
- The agent is the learner — it observes the current situation (the "state") and decides what action to take.
- The environment is everything the agent interacts with — it responds to the agent's action, updates the state, and hands back a reward or a penalty.
The agent's only goal is to choose actions that maximize reward over time. It has no instruction manual — just feedback, repeated over and over, often millions of times, until a winning strategy emerges.
Example: YouTube recommendations
This type of learning is best seen in YouTube recommendations. A user searches for a particular song, and the program shows a list of available songs. When the user selects a specific one, the system trains itself to remember that choice and deliver a similar result for future searches.
Every click is a small reward signal. Every skip or ignored recommendation is a small penalty. Over enough interactions, across enough users, the system learns which recommendations tend to lead to a click — without anyone ever handing it a labeled dataset of "correct" recommendations.
More examples of reinforcement learning
- Search recommendation engines — refining suggestions based on what users actually click
- Self-driving cars — learning driving policies by simulating millions of miles of driving and being rewarded for safe, efficient behavior
- Autocorrect tools — adjusting suggestions based on which corrections users accept versus reject
- Games where players compete against bots — the bot's strategy improves through repeated play, rewarded for winning moves and penalized for losing ones
The trade-off
Reinforcement learning is powerful for problems that involve a sequence of decisions rather than a single prediction, but it's also the most complex of the four types to set up. It needs a well-defined reward signal and an environment the agent can safely try things in — often a simulation, since letting an untrained agent experiment in the real world (a real car, a real financial account) can be risky before it has learned anything useful.
Key takeaway
Reinforcement learning trains an agent through trial and error: it acts, the environment responds with a reward or penalty, and the agent adjusts to favor higher-reward actions over time. Unlike the other three types of machine learning, it doesn't need a labeled or even unlabeled dataset upfront — just an environment to interact with and a clear signal of what counts as success.
What's next?
You've now covered all four types of machine learning. The last piece of the puzzle is practical: the Python libraries that data scientists actually use to build these systems.