DEV Community

Cover image for # Introduction to Machine Learning: How We Arrive at Linear Regression
Stacy Omwoyo
Stacy Omwoyo

Posted on

# Introduction to Machine Learning: How We Arrive at Linear Regression

Before we talk about Linear Regression, we first need to understand the bigger idea it belongs to Machine Learning.

Machine Learning is the reason applications today can:

  • recommend movies on Netflix,
  • suggest products on Amazon,
  • recognize faces on your phone,
  • and even predict house prices or exam scores.

But what exactly is Machine Learning?


What is Machine Learning?

Machine Learning is a branch of Artificial Intelligence where we teach computers to learn patterns from data instead of explicitly programming every rule.

Traditional Programming vs Machine Learning

In traditional programming:

You give the computer rules + data → it gives you answers.

In Machine Learning:

You give the computer data + answers → it learns the rules.


Simple Analogy

Think of teaching a child:

Traditional programming:

You say:

  • “If you see 2 + 2, always answer 4.”

You must manually define every rule.


Machine Learning:

You show the child many examples:

  • 1 + 1 = 2
  • 2 + 2 = 4
  • 3 + 3 = 6

Eventually, the child learns the pattern:

“Oh… adding numbers follows a pattern.”

That is exactly how Machine Learning works.


The Goal of Machine Learning

The main goal is simple:

To help machines learn patterns from data and make predictions on new, unseen data.


Types of Machine Learning

There are three main types:

1. Supervised Learning

The model learns from:

  • input (data)
  • output (correct answers)

Example:

  • house size → house price
  • study hours → exam score

This is where Linear Regression belongs.


2. Unsupervised Learning

The model is given data without answers and tries to find patterns on its own.

Example:

  • grouping customers by behavior
  • clustering similar items together

3. Reinforcement Learning

The model learns through:

  • rewards
  • mistakes
  • trial and error

Example:

  • game-playing AI
  • robotics navigation

From Machine Learning to Prediction Problems

Once we focus on supervised learning, we usually ask questions like:

  • “Can we predict a number?”
  • “Can we estimate a value?”
  • “Can we forecast future outcomes?”

These are called regression problems.


What is a Regression Problem?

A regression problem is when we try to predict a continuous numerical value.

Examples:

  • house price (e.g., 150,000)
  • temperature (e.g., 28°C)
  • exam score (e.g., 75%)

This is different from classification, where we predict categories like:

  • yes/no
  • spam/not spam
  • dog/cat

Enter Linear Regression

Now that we understand regression problems, we can introduce one of the simplest solutions:

Linear Regression

Linear Regression is a supervised learning algorithm used to predict continuous values by finding a relationship between input and output variables.


Why Linear Regression?

Because many real-world relationships can be approximated using a straight line.

Example:

  • More study hours → higher exam scores
  • Bigger houses → higher prices
  • More advertising → more sales

These relationships often follow a pattern that can be simplified as:

“As X increases, Y also increases (or decreases) in a predictable way.”


The Core Idea of Linear Regression

Linear Regression tries to draw a best-fit line through data points.

This line is used to:

  • understand patterns
  • and make predictions

Mathematically, it is written as:

y = mx + c
Enter fullscreen mode Exit fullscreen mode

Next we will do a deep dive into Linear Regression; Buckle up!

Top comments (0)