SlideShare a Scribd company logo
Regression
Linear Regression
• Simple Linear Regression
• Multiple Linear Regression
• Polynomial Regression
Non-Linear Regression
• Support Vector Regression (SVR)
• Decision Tree Regression
• Random Forest Regression
1. Simple Linear Regression
Simple Linear Regression
Ordinary Least Square
2. Multiple Linear Regression
A Caveat
Dummy Variables
3. Regression.pdf
3. Regression.pdf
Dummy Variable Trap
Statistical Significance
Tossing a coin
H0: Fair Coin
H1: Unfair Coin
0.5
0.25
0.12
0.06
0.03
0.01
P-Value
α = 0.05
P-Value (Probability Value)
Building ML Model Step-by-Step
Only 1 independent and 1
dependent variable
Many independent and 1
dependent variable
Which variable to include and which to exclude and Why?
Selecting the Right Variable
5 Methods of Building Models
1.All-in
2.Backward Elimination
3.Forward Selection
4.Bidirectional Elimination
Stepwise
Regression
All-in Model
Include all the variables in the model when:
• You have prior knowledge because of domain knowledge or such similar model has
been done previously.
• You have to because of some existing framework in the organization etc.
Backward Elimination
Backward Elimination
Forward Elimination
Bidirectional Elimination
All Possible Models
Multiple Regression- Python Code
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.read_csv('50_Startups.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 4].values
# Encoding categorical data
from sklearn.preprocessing import LabelEncoder, OneHotEncoder
labelencoder = LabelEncoder()
X[:, 3] = labelencoder.fit_transform(X[:, 3])
onehotencoder = OneHotEncoder(categorical_features = [3])
X = onehotencoder.fit_transform(X).toarray()
# Avoiding the Dummy Variable Trap
X = X[:, 1:]
# Splitting the dataset into the Training set and Test set
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2,
random_state = 0)
# Fitting Multiple Linear Regression to the Training set
from sklearn.linear_model import LinearRegression
regressor = LinearRegression()
regressor.fit(X_train, y_train)
# Predicting the Test set results
y_pred = regressor.predict(X_test)
Backward Elimination
# Building an optimal model using Backward Elimination
import statsmodels.regression.linear_model as sm
X = np.append(arr = np.ones((50,1)).astype(int),values = X, axis = 1)
X_opt = X[:,[0,1,2,3,4,5]]
regressor_OLS = sm.OLS(endog = y, exog = X_opt).fit()
regressor_OLS.summary()
X_opt = X[:,[0,3,4,5]]
regressor_OLS = sm.OLS(endog = y, exog = X_opt).fit()
regressor_OLS.summary()
3. Polynomial Linear Regression
Examine the data points as linear and parabolic
Parabolic Curve
3. Regression.pdf
4. Support Vector Regression
Nonlinear regression involves curves.
Support Vector Machine (SVM), is a classifier
predicting discrete categorical labels.
Support Vector Regression is a regressor
predicting continuous ordered variables.
Both use very similar algorithms, but predict
different types of variables.
In Simple Regression, we try to minimize the
error rate while in SVR we try to fit the error
within a certain threshold.
Support Vector Regression
Support Vector Regression
Support Vector Regression
Support Vector Regression
Support Vector Regression
Support Vector Regression
• Kernel : The function used to map a lower dimensional data into a higher
dimensional data.
• Hyper Plane: In SVM this is basically the separation line between the data
classes. Although in SVR we are going to define it as the line that will help
us predict the continuous value or target value.
• Boundary Line: In SVM, there are two lines other than Hyper Plane which
creates a margin. The support vectors can be on the Boundary lines or
outside it. This boundary line separates the two classes. In SVR the concept
is same.
• Support Vectors: This are the data points which are closest to the
boundary. The distance of the points is minimum or least.
Support Vector Regression
Support Vector Regression
Support Vector Regression
3. Regression.pdf
Support Vector Regression
Support Vector Regression
Support Vector Regression
Support Vector Regression
Support Vector Regression
5. Decision Tree Regression
Decision Tree Regression
Decision Tree Regression
Decision Tree Regression
Decision Tree Regression
Decision Tree Regression
Decision Tree Regression
Decision Tree Regression
Decision Tree Regression
6. Random Forest Regression
Random Forest Regression
Random Forest Regression
Evaluating Regression Models Performance
R Squared- Simple Linear Regression
Adjusted R2
Adjusted R2
Interpreting Linear Regression Coefficients
Interpreting Linear Regression Coefficients
Regression Model Pros and Cons
3. Regression.pdf

More Related Content

PDF
Supervised and Unsupervised Machine Learning
PDF
6. Association Rule.pdf
PDF
4. Classification.pdf
PDF
5. Types of Clustering Algorithms in ML.pdf
PDF
8. Deep Learning.pdf
PDF
1. Demystifying ML.pdf
PDF
7. Reinforcement Learning.pdf
PDF
2. Data Preprocessing.pdf
Supervised and Unsupervised Machine Learning
6. Association Rule.pdf
4. Classification.pdf
5. Types of Clustering Algorithms in ML.pdf
8. Deep Learning.pdf
1. Demystifying ML.pdf
7. Reinforcement Learning.pdf
2. Data Preprocessing.pdf

What's hot (20)

PPTX
Market Basket Analysis
PDF
Unsupervised Machine Learning Ml And How It Works
PDF
Linear Regression vs Logistic Regression | Edureka
PPTX
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
PDF
Confusion Matrix Explained
PPTX
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
PPTX
Linear Regression Analysis | Linear Regression in Python | Machine Learning A...
PDF
Model selection and cross validation techniques
PDF
Data preprocessing using Machine Learning
PPT
Characterization and Comparison
PPTX
K-Means Clustering Algorithm - Cluster Analysis | Machine Learning Algorithm ...
PDF
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
PPTX
Introduction to predictive modeling v1
PPTX
Curse of dimensionality
ODP
NAIVE BAYES CLASSIFIER
PDF
Logistic regression in Machine Learning
PPTX
Bayesian Neural Networks
PPTX
Cluster Analysis Introduction
PPTX
Exploratory data analysis
PDF
Bias and variance trade off
Market Basket Analysis
Unsupervised Machine Learning Ml And How It Works
Linear Regression vs Logistic Regression | Edureka
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Confusion Matrix Explained
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
Linear Regression Analysis | Linear Regression in Python | Machine Learning A...
Model selection and cross validation techniques
Data preprocessing using Machine Learning
Characterization and Comparison
K-Means Clustering Algorithm - Cluster Analysis | Machine Learning Algorithm ...
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Introduction to predictive modeling v1
Curse of dimensionality
NAIVE BAYES CLASSIFIER
Logistic regression in Machine Learning
Bayesian Neural Networks
Cluster Analysis Introduction
Exploratory data analysis
Bias and variance trade off
Ad

Similar to 3. Regression.pdf (20)

PPTX
SET-02_SOCS_ESE-DEC23__B.Tech%20(CSE-H+NH)-AIML_5_CSAI3001_Neural%20Networks.pdf
PDF
Regression analysis and its type
PPTX
Ai saturdays presentation
PDF
Module 5.pdf Machine Learning Types and examples
PDF
working with python
PPTX
Regression Analysis.pptx
PPTX
Regression Analysis Techniques.pptx
PPTX
Detail Study of the concept of Regression model.pptx
PPTX
Machine learning and linear regression programming
PPTX
linear regression in machine learning.pptx
PPTX
Linear Regression final-1.pptx thbejnnej
PPTX
Linear regression.pptx
PPTX
unit-5 Data Wrandling weightage marks.pptx
PDF
Introduction to machine learning
DOCX
Essentials of machine learning algorithms
PPTX
Day17.pptx department of computer science and eng
PDF
Machine learning Introduction
PDF
Basics of Machine Learning
PDF
Machine Learning deep learning artificial
PPTX
Intro to ml_2021
SET-02_SOCS_ESE-DEC23__B.Tech%20(CSE-H+NH)-AIML_5_CSAI3001_Neural%20Networks.pdf
Regression analysis and its type
Ai saturdays presentation
Module 5.pdf Machine Learning Types and examples
working with python
Regression Analysis.pptx
Regression Analysis Techniques.pptx
Detail Study of the concept of Regression model.pptx
Machine learning and linear regression programming
linear regression in machine learning.pptx
Linear Regression final-1.pptx thbejnnej
Linear regression.pptx
unit-5 Data Wrandling weightage marks.pptx
Introduction to machine learning
Essentials of machine learning algorithms
Day17.pptx department of computer science and eng
Machine learning Introduction
Basics of Machine Learning
Machine Learning deep learning artificial
Intro to ml_2021
Ad

More from Jyoti Yadav (12)

PDF
Part 4: Understanding the working of Smart Contracts
PDF
Part 3 Introduction to Cryptocurrency.pdf
PDF
Part 2 Blockchain Programming Using Python.pdf
PDF
Part 1: Introduction to Blockchain Fundamentals
PDF
Natural Language Processing Algorithm...
PDF
6. Web Publishing
PDF
5. Web Technology CSS Advanced
PDF
4. Web Technology CSS Basics-1
PDF
3. Web Technology Advanced HTML
PDF
2b. Web Technology HTML Basics-2
PDF
2a web technology html basics 1
PDF
1. web technology basics
Part 4: Understanding the working of Smart Contracts
Part 3 Introduction to Cryptocurrency.pdf
Part 2 Blockchain Programming Using Python.pdf
Part 1: Introduction to Blockchain Fundamentals
Natural Language Processing Algorithm...
6. Web Publishing
5. Web Technology CSS Advanced
4. Web Technology CSS Basics-1
3. Web Technology Advanced HTML
2b. Web Technology HTML Basics-2
2a web technology html basics 1
1. web technology basics

Recently uploaded (20)

PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Tartificialntelligence_presentation.pptx
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
Chapter 5: Probability Theory and Statistics
PDF
Approach and Philosophy of On baking technology
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Mushroom cultivation and it's methods.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Hybrid model detection and classification of lung cancer
PDF
Heart disease approach using modified random forest and particle swarm optimi...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Unlocking AI with Model Context Protocol (MCP)
Web App vs Mobile App What Should You Build First.pdf
Zenith AI: Advanced Artificial Intelligence
Building Integrated photovoltaic BIPV_UPV.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Programs and apps: productivity, graphics, security and other tools
Tartificialntelligence_presentation.pptx
cloud_computing_Infrastucture_as_cloud_p
Chapter 5: Probability Theory and Statistics
Approach and Philosophy of On baking technology
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Mushroom cultivation and it's methods.pdf
A comparative study of natural language inference in Swahili using monolingua...
MIND Revenue Release Quarter 2 2025 Press Release
NewMind AI Weekly Chronicles - August'25-Week II
Hybrid model detection and classification of lung cancer
Heart disease approach using modified random forest and particle swarm optimi...

3. Regression.pdf