DEV Community

Cover image for Machine Learning: A Beginner's Guide
Tom Chege
Tom Chege

Posted on

Machine Learning: A Beginner's Guide

Machine Learning (ML) is a branch of Artificial Intelligence (AI) that enables computers to learn patterns from data instead of relying on a long list of hand-written rules.

Think of it this way: instead of telling a computer exactly what to do in every situation, we show it examples, and it learns how to make good decisions on its own.

Before we begin, there are two important terms you'll hear often:

  • Features – the information the model uses to learn (e.g., house size, number of bedrooms, age of a car).
  • Label – the correct answer we want the model to learn (e.g., house price, "Spam", "Not Spam").

Machine learning generally falls into three categories.


1. Supervised Learning – Learning with a Teacher

Imagine studying for an exam with a teacher who already has the answer sheet.

You attempt a question, the teacher tells you whether you're right or wrong, and over time you improve.

That's exactly how Supervised Learning works.

The model is trained using labeled data, where every example already has the correct answer.

Example

A model learning to predict house prices might receive thousands of examples like:

  • Features: 3 bedrooms, 2 bathrooms, 200 sqm
  • Label: KES 45,000

After seeing enough examples, it can estimate the price of a house it has never seen before.

Common Tasks

Classification (predicting categories)

  • Spam or Not Spam
  • Fraud or Legitimate
  • Cat, Dog, or Bird

Regression (predicting numbers)

  • House prices
  • Monthly sales
  • Temperature tomorrow

Best for: Making predictions when you already know the correct answers from historical data.


2. Unsupervised Learning – Finding Hidden Patterns

Now imagine someone hands you a box of 10,000 books with no titles or categories.

Your job is to organize them.

You naturally begin grouping similar books together.

That's Unsupervised Learning.

The data has no labels, so the model must discover patterns on its own.

Common Tasks

Clustering

Finding groups of similar items.

For example, a business might discover customer groups like:

  • Budget sensitive shoppers
  • Luxury buyers
  • Frequent customers

Dimensionality Reduction

Sometimes data contains hundreds of features, many of which are repetitive.

Dimensionality reduction compresses that information into fewer, more useful features, making analysis faster and easier.

Best for: Exploring data and discovering insights you didn't know existed.


3. Reinforcement Learning – Learning by Experience

Think about learning to ride a bicycle. Nobody tells you the perfect balance. You try. You wobble. You fall. You adjust.

Eventually, you learn what works.

This is Reinforcement Learning.

Instead of learning from historical examples, an agent learns by interacting with an environment.

Good decisions earn rewards.

Bad decisions receive penalties.

The goal is simple:

Learn the sequence of actions that earns the highest reward over time.

Examples include:

  • Self-driving cars
  • Robotics
  • Game-playing AI
  • Recommendation systems that improve over time

Training vs. Prediction

Every machine learning model has two phases.

Training

The model studies historical data and learns patterns.

Prediction (Inference)

The trained model uses those patterns to make predictions on new data it has never seen before.

Think of it like studying for an exam first, then taking the actual exam later.


How Do We Know the Model Is Good?

A machine learning model isn't useful just because it makes predictions—it needs to make accurate predictions.

To test this, we evaluate the model using data it has never seen before.

If it performs well on new data, it has learned the underlying patterns rather than simply memorizing the training examples.


Which Type Should You Use?

Choose based on your goal:

If you want to... Use
Predict an outcome Supervised Learning
Discover hidden patterns Unsupervised Learning
Learn through trial and error Reinforcement Learning

Looking Ahead

In practice, data scientists often combine these approaches.

Modern AI systems, including Large Language Models (LLMs), also rely heavily on Self-Supervised Learning, where models create their own learning tasks from massive amounts of unlabeled data. This allows them to learn from billions of documents without humans manually labeling every example.


Conclusion

Machine Learning isn't a single technique: it's a toolbox. Understanding when to use each approach is the first step toward becoming a successful data scientist.

Top comments (0)