What is Machine Learning: easy example with Linear Regression
Discover what Machine Learning is with a simple example: how a machine can learn to classify new data using linear regression.
Machine Learning is a form of artificial intelligence (AI) that allows computers to learn from data without being explicitly programmed for every situation.
A Simple Example
Imagine you have 10 pairs of numbers. Each pair is associated with a result: 0 or 1. Essentially, we are saying that each pair belongs to a "class."
With a traditional algorithm, we would need to describe all possible rules to associate each pair with the correct class. But here's the problem: if an eleventh pair arrives that we've never seen before, the traditional algorithm wouldn't know what to do! This is because it only works for cases we have explicitly described. It is precise but not flexible.
With Machine Learning, however, we can use a method like linear regression to "learn" from the data. The algorithm analyzes the 10 initial pairs and tries to understand a general rule that separates the classes (those with a result of 0 and those with a result of 1).
To achieve this, the algorithm tests different hypotheses on how to distinguish the data, as if it were drawing various boundary lines between the points. Each time it makes an attempt, it checks how well this "rule" separates the data into different classes. If the separation is not good, the algorithm adjusts the rule, trying to improve the result. It's a process of trial and error that gradually leads to defining a rule that classifies the data more accurately.
When the eleventh pair arrives, the algorithm can make a prediction: even though it’s not guaranteed to be 100% correct, it can assign it to a class based on the learned rule.
Here is the graph illustrating how classification works in Machine Learning using linear regression:
- The blue points represent the pairs associated with class 0.
- The orange points represent those in class 1.
- The dashed green line separates the two classes: it’s the rule the model has learned.
- The red point represents a new pair (the eleventh): the model tries to classify it based on its position relative to the line.
In this example, Machine Learning demonstrates how it can adapt to new data not present during training!