Beginner lesson

Lesson 2: Types of Machine Learning

Beginner Course position: 2 of 30 Track: Machine Learning Tutorials

This lesson introduces the main categories of machine learning: supervised, unsupervised, and reinforcement learning within a structured machine learning path. It begins with intuition, moves into workflow thinking, and then shows a practical Python example with clear notes.

Concept and intuition

Types of Machine Learning is a core topic in machine learning because it shapes how we frame the problem, choose tools, and judge results. Each category solves a different type of problem and depends on different kinds of feedback from data or the environment.

When learning the main categories of machine learning: supervised, unsupervised, and reinforcement learning, do not focus only on formulas. The more important habit is to ask what the model is trying to learn, what assumptions it makes, and what could go wrong when the data is noisy, incomplete, or biased.

How it fits into a workflow

In a real project, the main categories of machine learning: supervised, unsupervised, and reinforcement learning sits inside a larger workflow: define the problem, prepare data, choose features, train a model, evaluate it carefully, and improve the system over time. Strong machine learning practice is iterative rather than one-shot.

This means you should connect the main categories of machine learning: supervised, unsupervised, and reinforcement learning to practical questions such as: What data is available? How will predictions be used? Which errors are most costly? How will the system be monitored after deployment? Those questions matter as much as model accuracy.

Common mistakes and practical advice

A common beginner mistake is to treat the main categories of machine learning: supervised, unsupervised, and reinforcement learning as a purely technical task. In practice, success depends on data quality, evaluation design, and the clarity of the business goal. Even a sophisticated model can fail if the data pipeline is weak or the target is poorly defined.

As you read the code example in this lesson, pay attention to how the inputs are shaped, how training and prediction are separated, and how the output is interpreted. Good coding habits make machine learning work more reliable, explainable, and easier to improve.

Three practical examples

Supervised learning

A model learns from past loan applications where the final decision is already known.

Unsupervised learning

A business groups customers into segments without giving the algorithm labels first.

Reinforcement learning

A game-playing agent learns actions that increase its long-term score.

Supervised vs unsupervised learning in code

This code example focuses on clarity rather than production scale. Read the comments, then study the notes below to understand why each step matters.

from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.cluster import KMeans

iris = load_iris()
X = iris.data
y = iris.target

supervised_model = LogisticRegression(max_iter=300)
supervised_model.fit(X, y)
print("Supervised prediction:", supervised_model.predict([X[0]]))

unsupervised_model = KMeans(n_clusters=3, random_state=42)
unsupervised_model.fit(X)
print("Cluster assignment:", unsupervised_model.predict([X[0]]))

Code walkthrough

  • The supervised model uses `y`, the known class labels, during training.
  • The unsupervised model ignores `y` and groups points based on similarity alone.
  • Both models use the same measurements, but their learning goals are different.
  • This is a good reminder that the problem definition determines the algorithm.

Summary and key takeaways

  • Supervised learning uses labeled data; unsupervised learning uses unlabeled data.
  • Reinforcement learning learns from actions and rewards over time.
  • The same raw dataset can support different learning tasks.
  • Choosing the right learning type is the first design decision in a project.

Exercises

  • Classify these problems as supervised, unsupervised, or reinforcement: fraud detection, topic grouping, robot navigation.
  • Why is supervised learning usually easier to evaluate?
  • Write one original example of unsupervised learning.
  • What does KMeans output in the code example?

Continue your learning