Regression via
Mathematical
Functions
Linear Regression
 Linear regression is defined as an algorithm that provides a
linear relationship between an independent variable and a
dependent variable to predict the outcome of future events.
 It is a statistical method used in data science and machine
learning for predictive analysis.
 The regression model predicts the value of the dependent
variable, which is the response or outcome variable being
analyzed or studied.
 Linear regression is a supervised learning algorithm that
simulates a mathematical relationship between variables and
makes predictions for continuous or numeric variables such as
sales, salary, age, product price, etc.
 This analysis method is advantageous when at least two
variables are available in the data, as observed in stock market
forecasting, portfolio management, scientific analysis, etc.
 A sloped straight line represents the linear regression model.
Applications of Linear Regression
In the figure,
 X-axis = Independent variable
 Y-axis = Output / dependent variable
Line of regression = Best fit line for a model
• Here, a line is plotted for the given
data points that suitably fit all the
issues.
• Hence, it is called the ‘best fit
line.’
• The goal of the linear regression
algorithm is to find this best fit line
seen in the figure.
Key benefits of linear regression
1. Easy implementation
The linear regression model is computationally simple to implement as it does not
demand a lot of engineering overheads, neither before the model launch nor during its
maintenance.
2. Interpretability
Unlike other deep learning models (neural networks), linear regression is relatively
straightforward. As a result, this algorithm stands ahead of black-box models that fall
short in justifying which input variable causes the output variable to change.
3. Scalability
Linear regression is not computationally heavy and, therefore, fits well in cases where
scaling is essential. For example, the model can scale well regarding increased data
volume (big data).
4. Optimal for online settings
The ease of computation of these algorithms allows them to be used in online settings.
The model can be trained and retrained with each new example to generate predictions
in real-time.
Linear Regression Equation
Let’s consider a dataset that covers RAM sizes and
their corresponding costs.
Dataset: RAM Capacity vs. Cost
If we plot RAM on the X-axis and its cost on the Y-axis, a line from the lower-
left corner of the graph to the upper right represents the relationship between
X and Y. On plotting these data points on a scatter plot, we get the following
graph:
Scatter Plot: PAM Capacity vs. Cost
• The regression model defines a linear function between the X and Y
variables that best showcases the relationship between the two.
• It is represented by the slant line seen in the above figure, where the
objective is to determine an optimal ‘regression line’ that best fits all
the individual data points.
Mathematically these slant lines follow the following equation,
Y = m*X + b
Where X = dependent variable (target)
Y = independent variable
m = slope of the line (slope is defined as the ‘rise’ over the ‘run’)
However, machine learning experts have a different notation to the above
slope-line equation,
y(x) = p0 + p1 * x
where,
•y = output variable. Variable y represents the continuous value that the model
tries to predict.
•x = input variable. In machine learning, x is the feature, while it is termed the
independent variable in statistics. Variable x represents the input information
provided to the model at any given time.
•p0 = y-axis intercept (or the bias term).
•p1 = the regression coefficient or scale factor. In classical statistics, p1 is the
equivalent of the slope of the best-fit straight line of the linear regression
model.
•pi = weights (in general).
Thus, regression modeling is all about finding the values for the unknown
parameters of the equation, i.e., values for p0 and p1 (weights).
The equation for multiple linear regression
• The equation for multiple linear regression is similar to the
equation for a simple linear equation,
i.e., y(x) = p0 + p1x1
-plus the additional weights and inputs for the different
features which are represented by p(n)x(n).
• The formula for multiple linear regression would look like,
y(x) = p0 + p1x1 + p2x2 + … + p(n)x(n)
PYTHON CODE FOR OBTAINING THE LINEAR REGRESSION RAM CAPACITY VS COST DATASET:
import numpy as np
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
# Get the data from the image
ram_capacity = np.array([2, 4, 8, 16])
ram_cost = np.array([12, 16, 28, 62])
# Create a linear regression model
model = LinearRegression()
# Fit the model to the data
model.fit(ram_capacity[:, np.newaxis], ram_cost)
# Get the slope and intercept of the regression line
slope = model.coef_[0][0] intercept = model.intercept_[0]
# Generate the regression line
ram_reg = np.linspace(min(ram_capacity), max(ram_capacity), 100)
cost_reg = slope * ram_reg + intercept
# Plot the data and the regression line
plt.scatter(ram_capacity, ram_cost)
plt.plot(ram_reg, cost_reg, color='red’)
plt.xlabel('Capacity’)
plt.ylabel('Cost’)
plt.title('Linear Regression of RAM Cost vs. RAM Capacity’)
plt.show()
CREDITS: This presentation template was created by
Slidesgo, and includes icons by Flaticon, and
infographics & images by Freepik
OUTPUT:

More Related Content

PDF
working with python
PPTX
DrSoomro_2588_20292_1_Lecture 9 (1).pptx
PPTX
Regression Analysis.pptx
PPTX
Regression Analysis Techniques.pptx
PPTX
PPTX
Linear Regression
PPT
Chapter05
PDF
Linear Regression
working with python
DrSoomro_2588_20292_1_Lecture 9 (1).pptx
Regression Analysis.pptx
Regression Analysis Techniques.pptx
Linear Regression
Chapter05
Linear Regression

Similar to linear regression in machine learning.pptx (20)

PPTX
numerical method chapter 5.pptxggggvvgggbg
DOCX
NPTEL Machine Learning Week 2.docx
PDF
The normal presentation about linear regression in machine learning
PDF
Simple linear regression
PPTX
unit 3_Predictive Analysis Dr. Neeraj.pptx
PDF
Lecture 5 - Linear Regression Linear Regression
PDF
R nonlinear least square
PPTX
Bootcamp of new world to taken seriously
PPTX
Applied Numerical Methods Curve Fitting: Least Squares Regression, Interpolation
PPTX
DataScienceUsingR-Dr.P.Rajesh.PRESENTATION
PPSX
Lasso and ridge regression
PPTX
Linear Regression.pptx
PPTX
Curve Fitting
PPTX
Machine learning session4(linear regression)
PDF
R linear regression
PPTX
AI & ML(Unit III).pptx.It contains also syllabus
PDF
Linear regression [Theory and Application (In physics point of view) using py...
PPTX
Linear regression.pptx
PPTX
manecohuhuhuhubasicEstimation-1.pptx
PPTX
Unit 03 - Consolidated.pptx
numerical method chapter 5.pptxggggvvgggbg
NPTEL Machine Learning Week 2.docx
The normal presentation about linear regression in machine learning
Simple linear regression
unit 3_Predictive Analysis Dr. Neeraj.pptx
Lecture 5 - Linear Regression Linear Regression
R nonlinear least square
Bootcamp of new world to taken seriously
Applied Numerical Methods Curve Fitting: Least Squares Regression, Interpolation
DataScienceUsingR-Dr.P.Rajesh.PRESENTATION
Lasso and ridge regression
Linear Regression.pptx
Curve Fitting
Machine learning session4(linear regression)
R linear regression
AI & ML(Unit III).pptx.It contains also syllabus
Linear regression [Theory and Application (In physics point of view) using py...
Linear regression.pptx
manecohuhuhuhubasicEstimation-1.pptx
Unit 03 - Consolidated.pptx
Ad

Recently uploaded (20)

PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Enhancing emotion recognition model for a student engagement use case through...
PPTX
Tartificialntelligence_presentation.pptx
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Five Habits of High-Impact Board Members
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PPTX
The various Industrial Revolutions .pptx
PDF
Hybrid model detection and classification of lung cancer
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PPT
Geologic Time for studying geology for geologist
Univ-Connecticut-ChatGPT-Presentaion.pdf
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Benefits of Physical activity for teenagers.pptx
Hindi spoken digit analysis for native and non-native speakers
Enhancing emotion recognition model for a student engagement use case through...
Tartificialntelligence_presentation.pptx
A comparative study of natural language inference in Swahili using monolingua...
A contest of sentiment analysis: k-nearest neighbor versus neural network
Five Habits of High-Impact Board Members
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
DP Operators-handbook-extract for the Mautical Institute
The various Industrial Revolutions .pptx
Hybrid model detection and classification of lung cancer
WOOl fibre morphology and structure.pdf for textiles
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Final SEM Unit 1 for mit wpu at pune .pptx
Taming the Chaos: How to Turn Unstructured Data into Decisions
Geologic Time for studying geology for geologist
Ad

linear regression in machine learning.pptx

  • 2. Linear Regression  Linear regression is defined as an algorithm that provides a linear relationship between an independent variable and a dependent variable to predict the outcome of future events.  It is a statistical method used in data science and machine learning for predictive analysis.  The regression model predicts the value of the dependent variable, which is the response or outcome variable being analyzed or studied.
  • 3.  Linear regression is a supervised learning algorithm that simulates a mathematical relationship between variables and makes predictions for continuous or numeric variables such as sales, salary, age, product price, etc.  This analysis method is advantageous when at least two variables are available in the data, as observed in stock market forecasting, portfolio management, scientific analysis, etc.  A sloped straight line represents the linear regression model. Applications of Linear Regression
  • 4. In the figure,  X-axis = Independent variable  Y-axis = Output / dependent variable Line of regression = Best fit line for a model • Here, a line is plotted for the given data points that suitably fit all the issues. • Hence, it is called the ‘best fit line.’ • The goal of the linear regression algorithm is to find this best fit line seen in the figure.
  • 5. Key benefits of linear regression 1. Easy implementation The linear regression model is computationally simple to implement as it does not demand a lot of engineering overheads, neither before the model launch nor during its maintenance. 2. Interpretability Unlike other deep learning models (neural networks), linear regression is relatively straightforward. As a result, this algorithm stands ahead of black-box models that fall short in justifying which input variable causes the output variable to change. 3. Scalability Linear regression is not computationally heavy and, therefore, fits well in cases where scaling is essential. For example, the model can scale well regarding increased data volume (big data). 4. Optimal for online settings The ease of computation of these algorithms allows them to be used in online settings. The model can be trained and retrained with each new example to generate predictions in real-time.
  • 6. Linear Regression Equation Let’s consider a dataset that covers RAM sizes and their corresponding costs. Dataset: RAM Capacity vs. Cost
  • 7. If we plot RAM on the X-axis and its cost on the Y-axis, a line from the lower- left corner of the graph to the upper right represents the relationship between X and Y. On plotting these data points on a scatter plot, we get the following graph: Scatter Plot: PAM Capacity vs. Cost
  • 8. • The regression model defines a linear function between the X and Y variables that best showcases the relationship between the two. • It is represented by the slant line seen in the above figure, where the objective is to determine an optimal ‘regression line’ that best fits all the individual data points. Mathematically these slant lines follow the following equation, Y = m*X + b Where X = dependent variable (target) Y = independent variable m = slope of the line (slope is defined as the ‘rise’ over the ‘run’)
  • 9. However, machine learning experts have a different notation to the above slope-line equation, y(x) = p0 + p1 * x where, •y = output variable. Variable y represents the continuous value that the model tries to predict. •x = input variable. In machine learning, x is the feature, while it is termed the independent variable in statistics. Variable x represents the input information provided to the model at any given time. •p0 = y-axis intercept (or the bias term). •p1 = the regression coefficient or scale factor. In classical statistics, p1 is the equivalent of the slope of the best-fit straight line of the linear regression model. •pi = weights (in general). Thus, regression modeling is all about finding the values for the unknown parameters of the equation, i.e., values for p0 and p1 (weights).
  • 10. The equation for multiple linear regression • The equation for multiple linear regression is similar to the equation for a simple linear equation, i.e., y(x) = p0 + p1x1 -plus the additional weights and inputs for the different features which are represented by p(n)x(n). • The formula for multiple linear regression would look like, y(x) = p0 + p1x1 + p2x2 + … + p(n)x(n)
  • 11. PYTHON CODE FOR OBTAINING THE LINEAR REGRESSION RAM CAPACITY VS COST DATASET: import numpy as np from sklearn.linear_model import LinearRegression import matplotlib.pyplot as plt # Get the data from the image ram_capacity = np.array([2, 4, 8, 16]) ram_cost = np.array([12, 16, 28, 62]) # Create a linear regression model model = LinearRegression() # Fit the model to the data model.fit(ram_capacity[:, np.newaxis], ram_cost) # Get the slope and intercept of the regression line slope = model.coef_[0][0] intercept = model.intercept_[0] # Generate the regression line ram_reg = np.linspace(min(ram_capacity), max(ram_capacity), 100) cost_reg = slope * ram_reg + intercept # Plot the data and the regression line plt.scatter(ram_capacity, ram_cost) plt.plot(ram_reg, cost_reg, color='red’) plt.xlabel('Capacity’) plt.ylabel('Cost’) plt.title('Linear Regression of RAM Cost vs. RAM Capacity’) plt.show()
  • 12. CREDITS: This presentation template was created by Slidesgo, and includes icons by Flaticon, and infographics & images by Freepik OUTPUT: