Open In App

Regression in machine learning

Regression, a statistical approach, dissects the relationship between dependent and independent variables, enabling predictions through various regression models.

The article delves into regression in machine learning, elucidating models, terminologies, types, and practical applications.



What is Regression?

Regression is a statistical approach used to analyze the relationship between a dependent variable (target variable) and one or more independent variables (predictor variables). The objective is to determine the most suitable function that characterizes the connection between these variables.

It seeks to find the best-fitting model, which can be utilized to make predictions or draw conclusions.



Regression in Machine Learning

It is a supervised machine learning technique, used to predict the value of the dependent variable for new, unseen data. It models the relationship between the input features and the target variable, allowing for the estimation or prediction of numerical values.

Regression analysis problem works with if output variable is a real or continuous value, such as “salary” or “weight”. Many different models can be used, the simplest is the linear regression. It tries to fit data with the best hyper-plane which goes through the points.

Terminologies Related to the Regression Analysis in Machine Learning

Terminologies Related to Regression Analysis:

Regression Types

There are two main types of regression:

Regression Algorithms

There are many different types of regression algorithms, but some of the most common include:

Regularized Linear Regression Techniques

Characteristics of Regression

Here are the characteristics of the regression:

Examples

Which of the following is a regression task? 

Solution : Predicting age of a person (because it is a real value, predicting nationality is categorical, whether stock price will increase is discrete-yes/no answer, predicting whether a document is related to UFO is again discrete- a yes/no answer).

Regression Model Machine Learning

Let’s take an example of linear regression. We have a Housing data set and we want to predict the price of the house. Following is the python code for it.




# Python code to illustrate 
# regression using data set
import matplotlib
matplotlib.use('GTKAgg')
   
import matplotlib.pyplot as plt
import numpy as np
from sklearn import datasets, linear_model
import pandas as pd
   
# Load CSV and columns
df = pd.read_csv("Housing.csv")
   
Y = df['price']
X = df['lotsize']
   
X=X.values.reshape(len(X),1)
Y=Y.values.reshape(len(Y),1)
   
# Split the data into training/testing sets
X_train = X[:-250]
X_test = X[-250:]
   
# Split the targets into training/testing sets
Y_train = Y[:-250]
Y_test = Y[-250:]
   
# Plot outputs
plt.scatter(X_test, Y_test,  color='black')
plt.title('Test Data')
plt.xlabel('Size')
plt.ylabel('Price')
plt.xticks(())
plt.yticks(())
   
  
# Create linear regression object
regr = linear_model.LinearRegression()
   
# Train the model using the training sets
regr.fit(X_train, Y_train)
   
# Plot outputs
plt.plot(X_test, regr.predict(X_test), color='red',linewidth=3)
plt.show()

Output: 

Here in this graph, we plot the test data. The red line indicates the best fit line for predicting the price.

To make an individual prediction using the linear regression model: 

print( str(round(regr.predict(5000))) )


Regression Evaluation Metrics

Here are some most popular evaluation metrics for regression:

Applications of Regression

Advantages of Regression

Disadvantages of Regression

Conclusion

Regression, a vital facet of supervised machine learning, navigates the realm of continuous predictions. Its diverse algorithms, from linear to ensemble methods, cater to a spectrum of real-world applications, underscoring its significance in data-driven decision-making.

Frequently Asked Question(FAQ’s)

What is regression and classification?

Regression are used to predict continuous values, while classification categorizes data. Both are supervised learning tasks in machine learning.

What is simple regression in machine learning?

Simple regression predicts a dependent variable based on one independent variable, forming a linear relationship.

What are the different regression algorithm?

Regression algorithms include linear regression, polynomial regression, support vector regression, and decision tree regression.


Article Tags :