DEV Community

Cover image for Regression in Machine Learning

Posted on

Regression in Machine Learning

Introduction to Machine Learning

Machine learning is a powerful field of study that revolves around teaching computers to learn from data and make predictions or decisions without being explicitly programmed for each task. In today's world, machine learning is everywhere, from recommendation systems on streaming platforms like Netflix to virtual assistants like Siri and Alexa, and even in medical diagnostics and autonomous vehicles.

Now, what are the things needed to learn machine learning?

As you embark on your journey into machine learning, there are myriad concepts to grasp. Among these, regression stands as a cornerstone—a fundamental principle essential for understanding predictive modeling. In this article, we'll delve into regression, unpacking its complexities in a simple and accessible manner.

So what is regression? Let's find out what it is in a simple way! ....start

What is Regression?

In the realm of machine learning, regression is a fundamental concept that serves as a cornerstone for understanding predictive modeling. Let's demystify regression in a straightforward manner.

Understanding Regression

If I want to summarize to confuse you, the general concept of regression is:
"Creating a relationship between variables that are related to each other and between variables that are not related to each other"

Let's explain the concept of regression more simply

The Blind Friend and Fruits

Imagine you have a friend who is blind and has always been eager to learn about fruits
(such as shape, taste, name, etc.) asks you to guide him to learn

For example, in the first step, you give him an apple, he does not know what an apple is! And confused and maybe a little embarrassed!
How do you describe an apple: its shape is round, its color is red, and its taste is crunchy
Your friend writes all the information you gave him in his mind and saves it under the name apple
As you present more fruits - bananas, oranges, etc., your friend will learn to recognize each fruit based on its characteristics and information, and with each encounter, based on its name, taste, and appearance. Understand the fruit. communicate
Over time, your friend will learn more fruits and become skilled in recognizing fruits, and when you say the name of each fruit, he will clearly recognize the appearance of its taste.

Well, was it understandable for you??

Analogies to Machine Learning

Now, let's draw parallels between this fruit-learning scenario and machine learning:

Data Input

Just as you provided information about fruits to your friend, machine learning algorithms require data inputs—attributes like size, color, and texture.


In machine learning, data is the fuel that powers algorithms. This data consists of various attributes or features, such as numerical values, categorical labels, or even images. For instance, if we were predicting house prices, the features could include square footage, number of bedrooms, and neighborhood.


Assigning names to fruits parallels the labeling process in machine learning, where data points are tagged with corresponding outcomes or labels.


Labels provide the ground truth for the learning process. In supervised learning—where regression typically falls—each data point is associated with a label representing the correct answer or outcome. For instance, in a dataset of house prices, each data point would have an associated price label. These labels serve as the basis for the algorithm to learn and make predictions.

Learning Mechanism

Your friend's ability to recognize patterns mirrors the learning process in machine learning algorithms, which analyze data to identify underlying trends and relationships.


Machine learning algorithms learn by identifying patterns and relationships within the data. They use various techniques to discern these patterns, such as linear regression, decision trees, or neural networks. Through iterative processes like gradient descent or backpropagation, algorithms adjust their parameters to minimize errors and improve predictions.


Machine learning algorithms learn by identifying patterns and relationships within the data. They use various techniques to discern these patterns, such as linear regression, decision trees, or neural networks. Through iterative processes like gradient descent or backpropagation, algorithms adjust their parameters to minimize errors and improve predictions.

Regression in Action: Predicting House Prices

Let's apply our newfound understanding of regression to a real world scenario: predicting house prices based on features like square footage, number of bedrooms, and location.

Step 1: Data Collection

We gather a dataset containing information about various houses size, number of rooms, location, and their corresponding prices.

Step 2: Data Preprocessing

Before feeding the data into our regression model, we preprocess it by handling missing values, scaling features, and encoding categorical variables.

Step 3: Model Training

We select a regression algorithm let's say linear regression and train it on our preprocessed data. During training, the algorithm learns the relationships between the features and house prices.

Step 4: Evaluation and Prediction

After training, we evaluate the model's performance using metrics like mean squared error or R-squared. Once satisfied with its performance, we deploy the model to make predictions on new, unseen data.

Step 5: Informed Decision-Making

With our regression model in hand, we can now make informed decisions about real estate investments, pricing strategies, or market trends.

Conclusion: Unveiling the Essence of Regression

In this exploration of regression, we journeyed through a simple yet profound analogy: teaching a blind friend about fruits. Through this analogy, we uncovered the essence of regression a fundamental concept in machine learning.

Just as guiding our friend to recognize fruits by their characteristics illuminates the process of learning, regression algorithms discern patterns and relationships within data to make predictions. We related providing information about fruits to data input in machine learning, assigning names to fruits to labeling data points, and recognizing patterns in fruits to the learning mechanism in algorithms.

By applying regression to predicting house prices, we navigated through the steps of data collection, preprocessing, model training, evaluation, and prediction, showcasing the practical application of this concept.

In essence, regression serves as the guiding light that illuminates the path to meaningful insights in machine learning. Understanding regression empowers us to make informed decisions based on data patterns, whether it's in predicting house prices or unraveling complex phenomena.

As we continue our journey into the vast realm of machine learning, let's remember the simplicity and clarity found in everyday analogies, guiding us towards deeper understanding.

Communication and Feedback:

Have suggestions or questions about this article? Want to delve deeper into machine learning? Reach out to me on Twitter or Telegram!

Learning Journey:

If you're interested in learning machine learning with JavaScript and want to explore more, check out my GitHub repository where I document my learning journey:

GitHub logo m-mdy-m / machine-learning-journey

Learning machine learning in js (without framework)

Machine Learning Journey in JavaScript

Welcome to the Machine Learning Journey repository! This repository contains resources, code examples, and articles related to machine learning implemented in JavaScript.


This repository is dedicated to documenting my progress and learning experiences with Machine Learning in JavaScript. Here, I'll be sharing the challenges I'm working on, the concepts I'm learning, and the resources I find helpful.

Related Articles


  1. Ensure you have Node.js installed. You can download it from
  2. Clone this repository to your local machine.



Before cloning and running the projects, make sure you have the following installed:

Remember, every step in the learning process brings us closer to mastering the art of machine learning. Keep exploring, keep learning, and let's journey together towards mastery! 🚀🤖

Top comments (0)