ML Exam #3

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/28

encourage image

There's no tags or description

Looks like no tags are added yet.

29 Terms

1
New cards

Discriminative Classifier

Logistic regression; model boundary between classes directly

2
New cards

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

3
New cards

Using Generative Classifiers

  1. Stability when classes separate well

  2. Handle small sample sizes

  3. More than two classes present


4
New cards

LDA and Bayes Theorem

  1. Prior: base rate

  2. Likelihood: how typical are this observations numbers for each group based on group mean and spreads

  3. Posterior: updated probability


5
New cards

Linear Discriminant

A score; a weighted sum of predictors, choosen so the two groups land as far apart as possible

6
New cards

LDA Assumptions

  1. Every class shares the same covariance structure

    1. Same spread, shape, and correlation between predictors

  2. Normality in the predictors


7
New cards

QDA

Boundary can curve

No covariance assumption

No discriminant coefficients

8
New cards

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

9
New cards

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

10
New cards

LDA: Multiple classes

produces min(p, K-1) discriminant functions

  • p: number of predictors

  • K: number of classes


11
New cards

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.

12
New cards

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


13
New cards

K Nearest Neighbors

  1. Finds the K training observations closest to it

  2. Takes a majority vote among those neighbors

  3. Assigns the most common class


<ol><li><p>Finds the K training observations closest to it</p></li><li><p>Takes a majority vote among those neighbors</p></li><li><p>Assigns the most common class</p></li></ol><p></p>
14
New cards

Bayes classifier

for every possible observation, the true probability of “Yes” given predictors

  1. Bayes error rate: lowest test error rate possible

  2. 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


15
New cards

KNN Trade Off

Small K: flexible (variance)

Large K: rigid (bias)

16
New cards

Choosing K

  1. Split into training and test sets

  2. Choose candidate values of K

  3. Use cross-validation within the training set to compare them

  4. Select K, refit on the training data, and evaluate once on the test set


17
New cards

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

<p>Because K measures closeness with Euclidean distance, units matter (larger spreads overwhelm signals)</p><p>Standandardization is required to normalize mean and standard deviation</p><p>Categorical variables maintain larger spreads under standardization as a category get rarer</p>
18
New cards

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.

19
New cards

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


20
New cards

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


21
New cards

Disadvangtages of a Single Split

  1. High variance. Which observations land in the test set changes the answer a lot

  2. 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


22
New cards

Cross Validation

  1. Shuffle the observations and deal them into k groups of equal size. Each group is a fold.

  2. 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.

  3. 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

  4. Average the k errors


23
New cards

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

24
New cards

Down-sampling

Throw away majority-class rows until the two classes match

25
New cards

Up-sampling

Duplicate minority-class rows, sampling with replacement, until the two classes match

26
New cards

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

27
New cards

Thresholds vs. Resampling

  1. 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.

  2. Resampling:

    1. 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.

    2. When the minority is too thin to learn from at all.

Always consider costs

28
New cards

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

29
New cards

Fold SD

describes how much the error estimate moves from fold to fold