Professional Documents
Culture Documents
Session 16 - 17 Nov8-10th
Session 16 - 17 Nov8-10th
Science
Session 16
Monday, 8th November 2021
Recap
• Time series analysis
– Types of data (stationary, non-stationary, seasonal)
– Metrics for evaluating effectiveness of one
technique over another (MAD, MSE etc.)
– Techniques
• Simple moving average
• Weighted average
• Exponential smoothing
• Additive seasonality adjusted forecasting
Classification Models
• Supervised Learning
– Show what to recognize (using labeled “training” data)
– Test how good is the model on the basis of unseen
(validation/test) data
– For now we will talk about classification models with
categorical/class/group outcome
• Techniques we will briefly discuss
– KNN (k-nearest neighbor)
– Logistic Regression
k-NN k-Nearest Neighbors
• Classify or predict an outcome of a new
observation
– by observing the k most similar observations from
the training set
– Similarity defined in terms of Euclidean distance
– New observation belongs to a group if the
percentage of its k nearest neighbors in that group
is greater than or equal to a cutoff value
How does kNN classification work?
• “Learn” to differentiate between observations by looking
at “K” neighboring/nearby observations
Y = b0 + b1*X1
Line of best fit
1
Classification Rule
Outcome Class
Y = b0 + b1*Feature1
Line of best fit
1
Outcome Class
Any other
challenges?
Assumptions
Outcome values
0
X1new cutoff X1
Logistic Regression Classification
• Classification technique based on supervised learning
• Predict the probability of being in one class or
another
P(Class = 1) = b0 + b1*X1 + b2*X2 + … + bn*Xn
• Probability that you are in class 0 or 1 should add up
to 1
– Truncate? Not ideal
• Find a mathematical form that can provide values
between 0 and 1
One Approach
• P = b0 + b1*X1
• P = eb0 + b1*X1 >= 0
• P = eb0 + b1*X1 / (eb0 + b1*X1 + 1) now 0 <= P <= 1
• Re-arrange
• P(eb0 + b1*X1 + 1) = eb0 + b1*X1
• P = eb0 + b1*X1 – P(eb0 + b1*X1)
• P = (1 – P) eb0 + b1*X1
• P / (1 – P) = eb0 + b1*X1
• LN(P/(1 – P)) = b0 + b1*X1
Alternative way of thinking
• If p is the probability of the occurrence of an event
• p/q is the “odds” of the event where q is the
probability of the event not occurring i.e. q = 1 – p
• p/(1-p) is the “odds” of the occurrence of the event
• Logistic regression computes the Log odds of the
event
– So unit change in the beta weights (or coefficients)
represents affect on the log odds of the outcome