linear regression
linear regression
➢ Common applications: Predicting house prices, stock trends, sales forecasting, etc.
coefficients.
➢Regression Coefficients:
✓These coefficients (βi, wi) are the weights assigned to each input feature x.
✓They determine how much each input feature contributes to the output y.
Graphical Representation:
Scatter Plot of Data Points: We'll plot the given data points, where each point
represents a pair of weight and height values.
Best Fit Line: We'll draw the line that best fits the data points according to the linear
regression model. This line minimizes the sum of the squared errors between the actual
data points and the line.
Residuals (Errors): We'll show the vertical distances (residuals) between the data points
and the regression line, highlighting the concept of minimizing these distances.
Model Parameters:
Slope (w1): let it be 0.361 (approximately)
This means that for every unit increase in weight, the height is expected
to increase by about 0.361 units.
Intercept (w0): let it be 9.11 (approximately)
This is the height when the weight is zero. While it might not be
meaningful in a practical context, it is essential for defining the
regression line.
Geometric Intuition:
The best fit line attempts to capture the linear relationship between weight
and height. The slope indicates the direction and steepness of this
relationship.
Minimizing the residuals ensures that the line is as close as possible to all the
data points, providing the best possible predictions.
Finding a line to best fit the data points using Ordinary
Least Squares (OLS) regression
Concept of residuals and squared errors in the
context of linear regression.
Key Points:
➢ The best-fit line is determined by minimizing the sum of the squared vertical
distances between the actual data points and the predicted values on the line.
➢ The residuals show how far off the predictions are from the actual data points.
➢ Why we use
square of
error?
➢ In linear regression,
we often use the
square of the errors,
rather than just the
errors themselves, to
measure how well the
model fits the data.
➢ This is called the Sum
of Squared Errors
(SSE).
Why Not Use Absolute Errors?
R squared: Coefficient of Determination
Ordinary Least Squares(OLS): Work on Best fit line
Gradient Descent: Work on the concept of Reduce the error
Math's to Find Slope and Intercept
➢ Identification of significant variables:
➢ It can be done during Exploratory Data Analysis (EDA)
➢ As well as during model building.
GRADIENT DESCENT
APPROACH:
Gradient Descent is a very generic optimization algorithm capable of finding optimal solutions to a wide range of
problems. The general idea of Gradient Descent is to tweak parameters iteratively in order to minimize a cost
function.
Suppose you are lost in the mountains in a dense fog; you can only feel the slope of the ground below your feet.
A good strategy to get to the bottom of the valley quickly is to go downhill in the direction of the steepest slope.
This is exactly what Gradient Descent does:
it measures the local gradient of the error function with regards to the parameter vector θ, and it goes in the
direction of descending gradient.
Once the gradient is zero, you have reached a minimum!
So, you start by filling θ with random values (this is called random initialization), and then you improve it
gradually, taking one baby step at a time, each step attempting to decrease the cost function (e.g., the MSE),
until the algorithm converges to a minimum
What is Gradient
Descent
➢ An important parameter in Gradient
Descent is the size of the steps,
determined by the learning rate
hyperparameter.
➢ Linear regression aims to minimize the squared loss, which measures the
discrepancy between the actual and predicted values.
➢ Threshold Accuracy:
➢ It’s indicated that an accuracy
threshold of 70-95% (or 0.7-0.95) is
desired.
➢ This is the target range for acceptable
model performance.
Regularization
Types of Regularization:
Types of Regularization
Types of Regularization
Application and Interpretation:
➢ When evaluating a linear regression model, several error metrics
help determine the model's performance.
➢ Each serves a slightly different purpose.
➢ The order of accuracy typically depends on the sensitivity of the
metric to outliers and the emphasis on specific error magnitudes.
➢ Here is a brief overview of the key error metrics, their order, and
when to use them:
Objective
Methodology
METHODOLOGY
Conclusion