Professional Documents
Culture Documents
LEARNING: REGRESSION VS
CLASSIFICATION
Week-15 Lecture-30
Agenda 2
Regression
Polynomial Regression.
Classification
Logistic Regression.
k-nearest neighbors.
Dependent Independent
Variable Variable
𝑦 𝑦 = 𝑏0 + 𝑏1𝑥
Constant Coefficient
Dependent
Variable
𝒙
Independent
Variable
5
Example: Linear Regression
Salary
Data
Example: Linear Regression (Ordinary 6
Least Squares)
7
Multiple features (variables)
2104 460
1416 232
1534 315
852 178
… …
��ො = 𝑏0 + 𝑏1𝑥
9
Multiple features (variables)
2104 5 1 45 460
1416 3 2 40 232
1534 3 2 30 315
852 2 1 36 178
…
Notatio n: … … … …
= number of features
= input (features) of training example.
= value of feature in training example.
10
Hypothesis:
Previously:
��ො = 𝑏0 + 𝑏1𝑥 (No More)
Now:
All in
Backward Elimination
Forward Selection
Bidirectional Elimination
Score Comparison
14
Building a Multivariate linear Regression model Cont.
15
Housing prices prediction
𝑦 = 𝑏0 + 𝑏1 × 𝑤𝑖𝑑𝑡ℎ + 𝑏2 × 𝑙𝑒𝑛𝑔𝑡ℎ
𝑥1
𝑥2
𝐴𝑟𝑒𝑎 = 𝑤𝑖𝑑𝑡ℎ × 𝑙𝑒𝑛𝑔𝑡ℎ
𝑦 = 𝑏0 + 𝑏1 × X
16
Polynomial regression
𝑏0 + 𝑏1𝑥 + 𝑏 2 𝑥 2
Price
(y) 𝑏0 + 𝑏1𝑥 + 𝑏 2 𝑥 2 + 𝑏 3 𝑥 3
Size (x)
��ො = 𝑏0 + 𝑏1𝑥 + 𝑏2𝑥2 +
𝑏3𝑥3 3
= 𝑏0 + 𝑏1 𝑠𝑖𝑧𝑒 + 𝑏2 𝑠𝑖𝑧𝑒 2 + 𝑏3 𝑠𝑖𝑧𝑒
17
Other Type of Regression
Importing Libraries
Data Import
Single predictor
P(Y ) 1 e
1
( b 0 b 1 X 1 i )
Multiple predictor
1
P(Y)
1e (b0 b1 X1b 2 X 2 ...bn Xn i )
Hasan, M.J.; Kim, J.-M. Fault Detection of a Spherical Tank Using a Genetic Algorithm-Based Hybrid Feature Pool and k-Nearest Neighbor Algorithm. Energies 2019, 12, 991.
Tree Based Methods
SuperDataScience
towardsdatascience.com