1/28
Looks like no tags are added yet.
Discriminative Classifier
Logistic regression; model boundary between classes directly
Generative Classifier
LDA & QDA; model what each class looks like (the size of the gap between group centers compared with the spread inside each group), then use Bayes’ Theorem to work backward to a probability
Using Generative Classifiers
Stability when classes separate well
Handle small sample sizes
More than two classes present
LDA and Bayes Theorem
Prior: base rate
Likelihood: how typical are this observations numbers for each group based on group mean and spreads
Posterior: updated probability
Linear Discriminant
A score; a weighted sum of predictors, choosen so the two groups land as far apart as possible
LDA Assumptions
Every class shares the same covariance structure
Same spread, shape, and correlation between predictors
Normality in the predictors
QDA
Boundary can curve
No covariance assumption
No discriminant coefficients
QDA Trade Off
Flexibility costs parameters (high variance, low bias)
1 for the spread of each predictor
1 for how each pair of predictors moves together
QDA: for each group, double LDA
Requires a large dataset
Covariance matrix
a square matrix that shows the variance of each variable along its main diagonal and the covariance between every pair of variables in its off-diagonal entries
LDA: Multiple classes
produces min(p, K-1) discriminant functions
p: number of predictors
K: number of classes
Proportion of trace
With three classes, LDA gives you two discriminant functions, LD1 and LD2, instead of one. The proportion of trace tells you how much of the separation between groups each one is responsible for.
Parametric
Assumes something about the shape of the boundary before it ever sees the data
Logistic regression: assumes a linear decision boundary
LDA: assumes multivariate normal classes with equal covariance
QDA: assumes multivariate normal classes with different covariances
K Nearest Neighbors
Finds the K training observations closest to it
Takes a majority vote among those neighbors
Assigns the most common class

Bayes classifier
for every possible observation, the true probability of “Yes” given predictors
Bayes error rate: lowest test error rate possible
Benchmark; impossible to achieve in reality
KNN: it estimates the probabilities from the training points in a small neighborhood, assuming the true probability is roughly constant nearby
Converges to the Bayes Classifier as training set grows and K/n approaches zero
KNN Trade Off
Small K: flexible (variance)
Large K: rigid (bias)
Choosing K
Split into training and test sets
Choose candidate values of K
Use cross-validation within the training set to compare them
Select K, refit on the training data, and evaluate once on the test set
Feature Scaling
Because K measures closeness with Euclidean distance, units matter (larger spreads overwhelm signals)
Standandardization is required to normalize mean and standard deviation
Categorical variables maintain larger spreads under standardization as a category get rarer

Curse of Dimensionality
In high dimensions, everything is far apart. The volume of space grows exponentially with p, so the same number of points becomes vanishingly sparse.
KNN Advantages
No assumed form for the boundary
Simple enough to explain to anyone
No training phase at all, so adding data means just storing it
Multi-class works naturally
KNN Disadvantages
The curse of dimensionality
A need for large samples
No global explanation, since there are no coefficients, no p-values, no significance tests
Prediction is expensive
It is helpless without scaling
Lazy learning: fitting is storing the data, so all the work happens at prediction
Model is the size of the training set
More data makes KNN better and slower
Disadvangtages of a Single Split
High variance. Which observations land in the test set changes the answer a lot
Upward bias: A model fit on fewer observations is a slightly worse model, so its test error overstates what the full-data model would do
Cross Validation
Shuffle the observations and deal them into k groups of equal size. Each group is a fold.
For fold 1: set it aside as the test set, fit the model on the other k−1 folds, score it on fold 1. Record the error.
Repeat for fold 2, fold 3, through fold k. Every observation is in the test set exactly once and in the training set k−1 times
Average the k errors
Cross Valiadation and Linear Regression
take the coefficients from $finalModel and the error from $results, as the model’s error are calculated on the same observations it was fit to
Down-sampling
Throw away majority-class rows until the two classes match
Up-sampling
Duplicate minority-class rows, sampling with replacement, until the two classes match
Disadvangtages of Resampling
Up-sampling and down-sampling both push the model to the same place: the baseline model with its cutoff dropped to about the base rate
Thresholds vs. Resampling
Thresholds: It costs nothing, keeps the model intact, and lets you set the operating point based on costs. For logistic regression and LDA, it reproduces everything resampling does.
Resampling:
When the probability dial is coarse or missing. KNN with K = 5 produces probabilities of 0, 0.2, 0.4, 0.6, 0.8, 1 and nothing in between; a threshold of 0.05 and a threshold of 0.2 are the same threshold. Tree-based methods you will meet later behave similarly. There, changing the training mix does something a cutoff cannot.
When the minority is too thin to learn from at all.
Always consider costs
Leave-One-Out Cross-Validation
fit on all other observations, predict the one you left out
Low bias with more data
High variance; error rates are highly correlated
cv = 5 or cv = 10 balances best
Fold SD
describes how much the error estimate moves from fold to fold