EDUCBA

EDUCBA

MENUMENU
  • Blog
  • Free Courses
  • All Courses
  • All in One Bundle
  • Login
Home Data Science Data Science Tutorials Machine Learning Tutorial What is Regression?

What is Regression?

Priya Pedamkar
Article byPriya Pedamkar

Updated May 23, 2023

what is regression

Introduction to Regression

Now let us first understand What is regression?  and why we use it. This is a predictive modeling technique in which we find the relationship between independent and dependent variables. It is mainly used for time series modeling, forecasting, and finding causal relationships between the variables.

Start Your Free Data Science Course

Hadoop, Data Science, Statistics & others

Why do we use regression? For example, we can use this model to estimate the price of houses based on the data collected in the past years and define a curve. Based on this curve, we can make predictions about the houses. It analysis also helps us to compare the effects of variables measured in different scales. This analysis also helps to identify the impact of an independent variable or the strength of it on a dependent variable.

What is Regression?

It is a method to determine the statistical relationship between a dependent variable and one or more independent variables. The change in the independent variable is linked to altering the dependent variables. This can be broadly classified into two major types.

  1. Linear Regression
  2. Logistic Regression

Types of Regression

It has seven types, but Linear and Logistic Regression are mainly used. These are the basic and simplest modeling algorithms. We will discuss both of these in detail here.

1. Linear Regression

  • The simplest case of linear regression is to find a relationship using a linear model (i.e. line) between an input-independent variable (input single feature) and an output-dependent variable. This is called Bivariate Linear Regression.
  • On the other hand, when there is a linear model representing the relationship between a dependent output and multiple independent input variables is called Multivariate Linear Regression.
  • The dependent variable is continuous and independent variables may or may not be continuous. We find the relationship between them with the help of the best-fit line, also known as the Regression line. The equation of a line is,

y = m * x + b

Where,

  • x: Independent Variable
  • y: Dependent Variable
  • m: Slope of Line
  • b: y Intercept

The most common method is the Least Square Method to evaluate the best-fit line. This method calculates the regression line by minimizing the least squared error between the regression line and the data points. Another method to find this line is also called the R Squared analysis.

It is particularly useful when the relationship between the input variables and the output is not very complex. Also, note that it is very sensitive to outliers.

Syntax in Python:

The Python library named sklearn contains an inbuilt function; we will use LinerRegression from sklearn.

Let us first install the sklearn package.

pip install scikit-learn
from sklearn.linear_model import LinearRegression
linearReg = LinearRegression()

To train the model, we will use the fit() function.

linearReg.fit(x_train, y_train)

2. Logistic Regression

  • It is used when the output is categorical. It is more like a classification problem. The output can be Success / Failure, Yes / No, True/ False, or 0/1. There is no need for a linear relationship between the dependent output variable and independent input variables.
  • If the output has only two possibilities, it is called Binary Logistic Regression. If the dependent output has more than two output possibilities and there is no order, it is called Multinomial Logistic Regression. If an order is associated with the output and has more than two output possibilities, it is called Ordinal Logistic Regression.
  • For example, you want to create a model identifying whether the breast cancer is malignant(1) or benign(0). For example, if you want to classify if the input email is spam(1) or not (0).

The Sigmoid function can better explain it.

hΘ (x) = sigmoid (Z)

Sigmoid Function:

sig(t) = 1 / 1+e−t

what is regression

The sigmoid function is the S-shaped curve. If the value goes near positive infinity, the predicted value will be 1. Similarly, the predicted value will be 0 if it goes negative infinity.

Syntax in Python:

For the implementation of logistic regression in Python, an inbuilt function is available in scikit- learn library of Python. For that first install scikit-learn using pip install.

from sklearn.linear_model import LogisticRegression logisticRegr = LogisticRegression()

To train the model, we will use the fit() function.

logisticRegr.fit(x_train, y_train)

Conclusion

It is necessary to choose the right Regression model based on the dependent and independent variables of your data and the dimensionality of the data. Before selecting any model, it is necessary to explore data. Different evaluation metrics can be used to compare the model’s goodness, like R Squared, Root Mean Square Error, Confusion Matrix, F1 score, etc.

Recommended Articles

This is a guide to What is Regression? Here we discuss what it is. Along with the two types of it in detail. You can also go through our other related articles to learn more –

  1. Machine Learning Techniques
  2. Application of Deep Learning
  3. Importance of Artificial Intelligence
  4. Statistical Analysis Types
All in One Excel VBA Bundle
500+ Hours of HD Videos
15 Learning Paths
120+ Courses
Verifiable Certificate of Completion
Lifetime Access
Financial Analyst Masters Training Program
2000+ Hours of HD Videos
43 Learning Paths
550+ Courses
Verifiable Certificate of Completion
Lifetime Access
All in One Data Science Bundle
2000+ Hour of HD Videos
80 Learning Paths
400+ Courses
Verifiable Certificate of Completion
Lifetime Access
All in One Software Development Bundle
5000+ Hours of HD Videos
149 Learning Paths
1050+ Courses
Verifiable Certificate of Completion
Lifetime Access
Primary Sidebar
All in One Data Science Bundle2000+ Hour of HD Videos | 80 Learning Paths | 400+ Courses | Verifiable Certificate of Completion | Lifetime Access
Financial Analyst Masters Training Program2000+ Hours of HD Videos | 43 Learning Paths | 550+ Courses | Verifiable Certificate of Completion | Lifetime Access
Footer
About Us
  • Blog
  • Who is EDUCBA?
  • Sign Up
  • Live Classes
  • Certificate from Top Institutions
  • Contact Us
  • Verifiable Certificate
  • Reviews
  • Terms and Conditions
  • Privacy Policy
  •  
Apps
  • iPhone & iPad
  • Android
Resources
  • Free Courses
  • Database Management
  • Machine Learning
  • All Tutorials
Certification Courses
  • All Courses
  • Data Science Course - All in One Bundle
  • Machine Learning Course
  • Hadoop Certification Training
  • Cloud Computing Training Course
  • R Programming Course
  • AWS Training Course
  • SAS Training Course

ISO 10004:2018 & ISO 9001:2015 Certified

© 2023 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

Let’s Get Started

By signing up, you agree to our Terms of Use and Privacy Policy.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

By signing up, you agree to our Terms of Use and Privacy Policy.

This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy. By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more