chp6 (10) Fam
chp6 (10) Fam
00
KB/S lO78%
linear regression
5 MultinomialLogistic Reareccion
+ Ask follow-up...
9:05 6.00
KB/S a1ll78%
simple linearregression
What is Simple Linear Regression?
Simple linear regression isa way to
understand the relationship between two
things: one thing we want to predict (called
the dependent variable) and one thing we
use tomake that prediction (called the
independent variable).
How It Works
"y=mx +b
+ Ask follow-up...
9:05 6.001ilO78%
KB/S
Key Points
Straight Line: The relationship is
represented by a straight line on a
graph.
One Predictor: It only uses one
independent variable to make
predictions.
Easy to Understand: It's one of the
simplest methods in statistics and
machine learning.
In summary, simple linear regression helps
us see howone thing affects another and
allows us to make predictions based on
that relationship!
+ Ask follow-u..
78%
multiple linear
regression
Multiple linear regression (MLR) is a
statistical method used to predict the
outcomne of one variable based on two or
more other variables.
Key Points
" Purpose: MLR helps understand how
multiple factors influence a single
result, like how various factors affect a
house's price(size, location, age).
Equation: The relationship is
expressed as:
Key Points
" Purpose: MLR helps understand how
multiple factors influence a single
result, like how various factors affect a
house's price (size, location, age).
" Equation: The relationship is
expressed as:
+ Ask follow-up...
9:08 1.90ull78%
KB/S
Example Problems
1500 3 10 300
1800 4 LO
5 400
2400 4 15 500
+ Ask follow-up..
9:08 0.04
KB/S uullO78%
1500 10 300
1800 4 5 400
2400 4 15 500
3000 LO
5 20 600
3500 5 650
Solution
1. Define Variables:
" Independent Variables (X): Size,
Bedrooms, Age
Dependent Variable (y): Price
+ Ask follow-up.
VOU WOuld fit a linear rearession
9:08 0.04lO78%
KB/S
Solution
1. Define Variables:
3. Make Predictions:
" After fitting the model, you would
input the values for the new
house:
" Size=2000
" Bedrooms = 3
Age = 12
4. Example Code:
python
import pandas as pd
+ Ask follow-up.
9:08 0.07O78%
KB/S
4. Example Code:
python
import pandas as pd
from sklea rn.linear_model
import LinearRegression
df = pd . DataFrame (data)
# Define X and y
X = df [['Size ', 'Bedrooms'
'Age']]
y = df['Price']
+ Ask follow-u..
9:08 0.06
KB/S
lO78%
# Define X and y
X = df [['Size ' , 'Bedrooms'
'Age']]
y = df['Price ']
model = LinearRegression ()
model.fit (X, y)
Formula:
1
MAE =÷)lyi
i=1
Example:
" Actual Prices: [100, 150, 200]
" Predicted Prices: [110, 140, 210]
Calculating MAE:
" Differences: [10, 10, 10]
" MAE = (10 +10+10) /3 = 10
Formula:
1H
MSE =
i=1
Example:
" Actual Prices: [100, 150, 200]
" Predicted Prices: [110, 140,210]
Calculating MSE:
Squared Differences: [(10), (10)2, (10)2]
- [100, 100, 100]
MSE = (100 + 1O0 + 100) /3 = 100
+ Ask follow-up.
intne same units as tne target variable.
9:10 097ll O77%
KB/S
Formula:
RMSE =MSE
Example:
Using the previous MSE of 100, we
calculate RMSE:
4. R-squared (R?)
What It Is: R² shows how wellyour model
explains the variability of the target
+ Ask follow-up.
9:10 1791l77%
KB/S
logistic regression
What is Logistic Regression?
Logistic regression is a method used in
machine learning to predict whether
something belongs to orne of two
categories. For example, it can help
determine if an email is "spam" or "not
spam," or if a patient hasa disease (yes or
no).
How It Works
+ Ask follow-up...
9:10 .00il O77%
KB/S
+ Ask follow-up...
O14
O.00l
KB/S O77%
all imp
1. Confusion Matrix
Aconfusion matrix is a table that shows
how wel your model predicted the classes.
It contains four key components:
Predicted Predicted
Positive Negative
Example:
True Positives (TP): Correctly
predicted positives (e.g., spam emails
correctly marked as spam).
" True Negatives (TN): Correctly
predicted negatives (e.g., non-spam
emails correctly marked as non
spam).
False Positives (FP): Incorrectly
predictedpositives (e.g., non-spam
+ Ask follow-up...
9:17 0.07ll O77%
KB/S
2. Accuracy
Accuracy measures how often the model is
correct.
Formula:
TP +TN TP + TN
TotalPredictions TP +TN + FP +.
Example:
If you have 80 correct predictions
100total predictions, the accuracy is:
80
Accuracy = 100
= 0.8 (or 80%)
3. Precision
Proaieian tallo uau baA monL af tha
+ Ask follow-up...
po
9:17 022llO77%
X
2. Accuracy
Accuracy measures how often the model is
Correct.
Formula:
TP +TN TP + TN
al Predictions TP + TN + FP+ FN
Example:
If youhave 80 correct predictions out of
100 total predictions, the accuracy is:
80
Accuracy 100
= 0.8 (or 80%)
3. Precision
3. Precision
Formula:
TP
Precision =
TP+ FP
Example:
If your model predicts 10 emails as spam
and only 7 are actually spam, the precision
is:
7 7
Precision = 0.7 (or 709
7+3 10
4. RecalI(Sensitivity)
Recall measures howmany actual positive
cases were correctly identified.
Formula:
TP
Recall =
+ Ask follow-up...
ExaipG.
9:17 .04l77%
KB/S
4. Recall(Sensitivity)
Recall measures how many actual positive
cases were correctly identified.
Formula:
TP
Recall
TP +FN
Example:
If there are 10actual spam emails and your
model identifies 7 of them, the recall is:
7 7
Recall =
7+3 10
=0.7 (or 70%)
5. F1 Score
Formula:
Precision x Recall
F1= 2 x
Precision + Recall
F
+ Ask follow-up.
the F1 score wOuld he
9:17 075l77%
KB/S
Example:
If precision is 70% and recall is also 70%,
the F1 score would be:
0.7 × 0.7 0.49
Fl= 2x =2 x = 0.7
0.7 +0.7 1.4
Example:
+ Ask follow-up.
9:17 075l77%
KB/S
Example:
An AUC of 0.8 means there's an 80%
chance that the model will rank a randomly
chosen positive instance higher than a
randomly chosen negative one.
Related
+ Ask follow-up.
+
9:24 11.0ull75%
KB/S
complex.
+ Ask follow-up..
Commn Tomni
9:24 6.00ull75%
KB/S
complex.
Key Points:
1. Overfitting captures noise; underfitting
micooo bau informatian
+ Ask follow-up.
pertormance, undertitting shows low