Introduction to Machine Learning

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

1/293

flashcard set

Earn XP

Description and Tags

FS2026

Last updated 12:46 PM on 8/12/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

294 Terms

1
New cards

Simplified diagram of machine learning

knowt flashcard image
2
New cards

Supervised Learning - Definition

Learning with training data that contains inputs together with correct outputs (= labels). The Goal here ist to predict the correct output.

3
New cards

Unsupervised Learning - Definition

Learning with training data that contains only inputs and no labels. The Goal here is to discover useful structure in the data.

4
New cards

Examples of supervised learning:

Classification, Regression, Structured prediction

5
New cards

Examples of unsupervised learning

Clustering, Anomaly detection, Dimensionality reduction, Generative Modeling

6
New cards

Simplified diagram of supervised learning:

Prediction y can also be called y^, or f^(x)

<p>Prediction y can also be called y^, or f^(x)</p>
7
New cards

Simplified diagram of unsupervised learning:

knowt flashcard image
8
New cards

Goals of unsupervised Learning: 2 concepts

1) Describe new input x relative to training data (is it similar, is it an anomaly?, etc.)
2) Generate new data x’ that looks similar to training data (Generative modeling)

9
New cards

Machine Learning Pipeline for linear Regression

Linear Regression is always linear functions, squared loss, closed-form, no matter the dimension

<p>Linear Regression is always linear functions, squared loss, closed-form, no matter the dimension</p>
10
New cards

Difference House Prices (Linear Regression) example between 1 Dimension and d Dimensions

1D: We only have one attribute x (x is 1D) → E.g. x = (size)
dD: We have d attributes → x is dD → E.g. x = (size, #bathrooms, …, years since construction)

11
New cards

How can the linear function class be represented in 1d?

knowt flashcard image
12
New cards

Linear function equation:

f(x) = w0 + w1*x with w0: y-Achsenabschnitt, w1: Steigung

13
New cards

Linear Regression:

Function Class F: Linear Functions

Training Loss L: Squared Loss

Optimization: We can use closed Form solution

14
New cards

Characteristics of different Losses: Squared, Huber, Asymmetric

Squared Loss: Symmetric → Overestimation and Underestimation are treated equally, large penalty on outliers (because grows quadratically)

Huber Loss: Ignores outliers

Asymmetric Losses: Weigh over- and underestimation differently

15
New cards

Feature Vector x in 1D:

X = (x1, …, xn) mit x1, …, xn 1D

E.g. x_i = (size)

<p>X = (x1, …, xn) mit x1, …, xn 1D</p><p>E.g. x_i = (size)</p>
16
New cards

Feature Vector x in dD:

X = (x1, …, xn) mit x1, …, xn dD

E.g. x_i = (size, #bathrooms, …, years since construction)

<p>X = (x1, …, xn) mit x1, …, xn dD</p><p>E.g. x_i = (size, #bathrooms, …, years since construction)</p>
17
New cards

Linear Regression Closed Form:

w = (X^TX)^(-1)X^Ty

18
New cards

19
New cards

What changes if we use nonlinear regression?

Function Class F: We can use nonlinear functions

Optimization: Gradient Descent can be used (it’s always used when there is no closed form or closed form is computationally expensive)

20
New cards

General Form of nonlinear functions in ML Pipeline:

Some ML models have fixed phi (linear regression, kernel regression, etc.), phi maps d dimensions (from input) to p dimensions

Nonlinear in x, linear in phi

<p>Some ML models have fixed phi (linear regression, kernel regression, etc.), phi maps d dimensions (from input) to p dimensions</p><p>Nonlinear in x, linear in phi</p>
21
New cards

Matrix notation of loss L(w) of nonlinear function (also squared loss)

knowt flashcard image
22
New cards

Why can/can’t we use closed form for nonlinear functions?

We can use it, we only have to replace X matrix with Phi matrix.
Problem: Phi^TPhi can have a high computational cost to compute and there is a lack of generality for different losses (other than squared loss)

→ That’s why we need gradient descent

23
New cards

What do we use Gradient Descent for?

It’s a general iterative algorithm to minimize our loss L(w) and thus find out our weight vector w for our model f.

24
New cards

Gradient Descent in 1D: 1. In which direction do we move? 2. How far in that direction? 3. When should we stop?

  1. In direction of sign of negative derivative at w_now

  2. nü~ = nü*|L’(w_now)| → In direction of nü

  3. Stop when it can’t improve much anymore, so for example when: |L(w_now) - L(w_previous)| <= epsilon

25
New cards

What changes when we execute Gradient Descent in nD than in 1D?

For minimizing L(w) we have multiple directions in which to go to. → We need gradient (because gradients point in direction of steepest descent)

26
New cards

Geometric Intuition of contour lines in relation with Gradient Descent:

  • Steepest direction is orthogonal to contour lines

  • Direction of steepest increase: ∇L(w)

  • Direction of steepest decrease: -∇L(w)

27
New cards

What does hold on contour lines?

On those lines the loss has the same value.

28
New cards

Gradient Descent algorithm:

knowt flashcard image
29
New cards

True or False: We can use machinery from linear regression to solve regression in nonlinear function spaces by just replacing the data matrix 𝑋 by the feature matrix Φ

True

30
New cards

How can we rewrite the Squared Loss in matrix notation?

knowt flashcard image
31
New cards

Which of the following statements are true?
(A) All convex functions have only one local minimum that is a global minimum
(B) For convex functions, all stationary points are local minima
(C) For convex functions, all stationary points are global minima

(B) and (C) are true immediately if you plug in ∇𝐿 𝑤 = 0 in first order condition

32
New cards

Relation Convexity and global/local minima

knowt flashcard image
33
New cards

Why does Gradient Descent work for linear Regression?

Because linear Regression with squared Loss is a convex problem. Convergence is only guaranteed for the convex case. (otherwise we can get stuck in local minima or diverge to infinity)

34
New cards

What holds for the 2 norm squared?

knowt flashcard image
35
New cards

What is Conditioning?

It tells us how nicely shaped the loss landscape is. If the contour lines (= same loss values) are more spheres we have a well conditioned case, and if they are more ellipses we have an ill conditioned case.

36
New cards

Well-conditioned case of GD?

λmax ​≈ λmin​, contour lines are almost circles, loss equally steep in all directions, GD works

37
New cards

Ill-conditioned case for GD

λmax​ » λmin, contour lines are stretched ellipses, one direction very steep, the other flat → small stepsize: slow in flat direction, large stepsize: oscillations in steep direction
→ Solution for ill-conditioned case → use Momentum/accelerated methods​

38
New cards

Momentum/accelerated methods to find minima:

Momentum speeds up flat directions, speeds up GD (Gradient Descent)

39
New cards

Why SGD (Stochastic Gradient Descent)?

It uses a different loss than GD (not gradient over all points but only on a random subset of points, which is called mini batch with batch size |S|). This saves memory, when the batch size is smaller than n
→ works because minibatch gradient is correct on average (Expectation value)

40
New cards

Full batch GD, Original SGD, Minibatch SGD?

Full batch: |S| = n, Original: |S| = 1, Minibatch: 1 < |S| < n (Full batch = normal GD)

41
New cards

Effect on batch size in SGD?

|S| small → cheap but noisy, but this can sometimes also escape saddle points

|S| large → expensive but stable (closer to GD, can more and more get stuck in stationary points)

42
New cards

What is convexity? Explain with the 3 conditions.

Function is convex if it has a “bowl shape”.


0-th order condition: Real function always below linear connection of two random points.

1-st order condition: Tangent of two points always below function.

2-nd order condition: Curvature is always non-negative .

43
New cards

What is strong convexity?

Stronger than convexity. It holds: strong convex → unique global minimum, It means that the loss landscape is curved enough so that there is only one best solution.

44
New cards
<p>Characterize the following functions:</p>

Characterize the following functions:

knowt flashcard image
45
New cards

Training Loss, Generalization Error and Estimation Error?

Training Loss: Measures error on trainings data D. L(f;D)

Generalization Error: Measures expected error on new data. L(f;P) (P is the joint distribution that we assume our test data is drawn from and our trainings data is randomly sampled from)

Estimation Error: Measures how far the learned model is from the ideal model f*.

46
New cards

Linear Regression, what underparametrized case, overparametrized case and n=d mean for the errors and amount of solutions for our problem.

Underparametrized n>d: More samples than parameters, if we increase n our model sees more data and thus the effect of noise gets averaged out, Estimation Error shrinks, usually unique solution

Overparametrized n<d: More parameters than samples, More DoFs than constraints from Data → infinitely many solutions, Training error can be zero, b.c. we can fit data perfectly

n=d: Possibly a unique solution

Main Message: More samples usually help, but in high dimensions (n<d) many different models can fit the training data perfectly, and not all of them generalize well.

47
New cards

Definition Model complexity

means how flexible the function class F is. F0 = constant functions, F1 = linear, F2 = quadratic, etc.

Higher model complexity → more flexible functions → Fit data better → Training error shrinks

48
New cards

Definition Underfitting

Model is too simple and can’t capture the true relationship.

49
New cards

Definition Overfitting:

Model is too complex and fits random noise in training data.

50
New cards

Overview: Relationship model complexity vs. Training/Generalization Error

knowt flashcard image
51
New cards

Sources for generalization error:

Bias, Variance, Irreducible noise

→ Important: Generalization Error can exist without noise because of Bias and Variance, from not being able to fit the function (bias) and/or from seeing only few samples (Variance)

52
New cards

Bias-Variance tradeoff in choosing model complexity

Simple Models: High Bias, Low Variance

Complex Models: Low Bias, High Variance

Good Models: Balance

53
New cards

Definition Bias and Variance with pictures in mind

Bias: Distance between average over all different models for different data sets D1, D2, .. and ideal model f*

Variance: Summarized Distance between individual models fD and average over all models.

<p>Bias: Distance between average over all different models for different data sets D1, D2, .. and ideal model f*</p><p>Variance: Summarized Distance between individual models fD and average over all models. </p>
54
New cards

Behavior Model Complexity vs. Generalization Error, Variance, Bias

knowt flashcard image
55
New cards

Training Loss and Generalization Error. Problem?

If we had access to joint distribution P, we could just compute generalization error (what we care about), but we only have data set D.

Problem: Training Error is too optimistic for estimating generalization error. Because model was explicitly chosen to minimize this error.

56
New cards

Main Idea to find a good model and a good estimate on generalization error of this model fD?

Split data into training data, for model training, and test data, to evaluate generalization error.

57
New cards

Definition Model Selection:

Which method M should we use to obtain a model that predicts well on unseen samples? Different models → different hyperparameters (= learning rate, batch size, polynomial degree, etc.)

58
New cards

Definition Model Evaluation:

Get sense for how well model f does in predicting unseen test samples.

59
New cards

For what is D_train, D_validation and D_test?

D_train: Used to fit model parameters

D_validation: Used to choose the best model bzw. the best hyperparameters

D_test: Used to estimate final generalization error

60
New cards

Which problem does cross validation solve?

When we have a too small dataset and its too wasteful to set aside both validation and test set.

61
New cards

How does k-fold cross validation work?

Given: Different Models, Amount of folds K, Dataset split into D_use and D_test

Goal: Find best Model

1) For each model: Split D_use into K folds, Use one fold as D_validation and other K-1 as D_train, Compute Validation Error for each fold → L_K(model), After all K folds, average the validation Error to get CV Error

2) In the end for each Model we have the CV Error

3) Choose Model with lowest CV Error

62
New cards

How can we control model complexity (such that we don’t overfit)?

Regularization

→ Smaller degree m

→ Smaller number of monomials active by limiting l1-norm (Lasso Regression)

→ Penalty on big weights by limiting l2-norm (Ridge Regression)

63
New cards

How does Bias and Variance change if we have stronger regularization (= bigger λ)

knowt flashcard image
64
New cards

Comparison Lasso vs. Ridge Regularization:

Lasso: Limits L1 norm (= absolute value of w) → encourages sparsity, because l1 penalty can set coefficients exactly to zero. Removes features.

Ridge: Limits L2 norm (= Length of vector w) → shrinks coefficients smoothly but usually does not set them to zero. Shrinks features.

65
New cards

Labels in Regression vs. Labels in Classification:

Regression: Labels y are continuous in R

Classification: Labels y are discrete (Multiclass more than two labels options and binary = 2)

66
New cards

What is a Decision Boundary

In Linear Binary Classification, where f(x) = 0 and there is a transition to one label to the other

67
New cards

What properties do we need for losses such that they are good for training? Which Loss is not usable for training?

  • Decreasing

  • Convex in its arguments

  • Differentiable
    → 0-1 Loss is not differentiable and not convex and therefore not suitable for training

68
New cards

Comparison Exponential Loss and Logistic Loss:

Exponential: Large penalty for mislabeled “outlier” points “far away” from boundary

Logistic: Less prone to noisy outliers

69
New cards

Is Training Loss with logistic loss convex?

Yes, but it depends if it has unique solution → Depends on if data linearly separable or not

70
New cards

What happens when GD minimizes logistic loss on linearly separable data?

The logistic loss can go closer and closer to zero by increasing ∥w∥.

GD does not converge to a finite w.
But it converges in the direction of the max margin solution

71
New cards

What is the max-margin classifier?

It chooses the separating hyperplane with the largest minimum distance to the training points.

72
New cards

What is the margin?

It measures the distance of the closest training point to the decision boundary.

Large margin means better separation.

73
New cards

What is hard-margin SVM?

Hard-margin SVM is for linearly separable data.

It finds a separating hyperplane with maximum margin.

74
New cards

What is soft-margin SVM?

Soft-margin SVM is for not linearly separable data.

It allows margin violations using slack variables.

75
New cards

Binary Classification

knowt flashcard image
76
New cards

Logistic Loss

knowt flashcard image
77
New cards
term image

Solution is (B): Because in (A) the red line does not separate anything. Thus this cannot be one vs. rest

78
New cards

Multiclass Classification:How can we naively train a model that classifies K classes?

One vs. Rest: For each class k in K, relabel class k as one class and the rest as the other class, then train a binary classifier → Results in K binary classifiers for K classes

79
New cards

Multiclass Classification: How can we train a model that classifies K classes simultaneosly?

By choosing Cross-Entropy Loss (=L_CE) as our loss.
L_CE small → True class score f_y(x) much larger than all others → we found correct label y

L_CE large → Other class has larger score → We didn’t find correct label y

80
New cards

Cross-entropy Loss with K = 2 corresponds to what?

Logistic Loss

81
New cards

Which Losses do we often take in binary classification and which in multiclass classification?

Binary: Logistic Loss

Multiclass: Cross-entropy Loss

82
New cards

Statistical model for training and test data. How can we graphically represent the marginal distribution P_x, Conditional distribution P_Y|x and joint distribution P?

knowt flashcard image
83
New cards

What holds for the best labeling function y*(x)?

knowt flashcard image
84
New cards

What is a robust generalization?

Asks whether a classifier still performs well, when the test distribution changes and is not the same anymore as the train distribution.

85
New cards

What is a Distribution Shift?

When P_train is not equal to P_test anymore

86
New cards

What is worst-group generalization?

Instead of only asking “How good is the model on average?”, we ask “How good is the model on the group (=subset of data) where it performs worst?

87
New cards

What is an Asymmetric Loss?

A Loss in which not all classification errors are equally bad. Sometimes it is worse if we have many FP (= False Positives) or FN (= False Negatives).

88
New cards

What are the two approaches for introducing asymmetric Losses?

  1. Weighted training loss: Train the model with different weights for different error types: L = c_FP*FPR + c_FN*FNR

  2. Threshold Tuning: Train one model f(x), then choose a threshold τ. Depending on τ we have a different classifier: y = +1 if f(x) > τ, y = -1 else.
    Changing τ changes the tradeoff between FP and FN

89
New cards

What is ROC curve?

Curve that shows tradeoff between TPR and FPR for all thresholds τ.

<p>Curve that shows tradeoff  between TPR and FPR for all thresholds τ. </p>
90
New cards

Binary Classification Pipeline vs. Multiclass Classification Pipeline

Binary: K = 2 → Cross-Entropy Loss = Logistic Loss and we only have ONE model

<p>Binary: K = 2 → Cross-Entropy Loss = Logistic Loss and we only have ONE model</p>
91
New cards

Problem of feature maps ϕ and motivation for kernel trick:

We apply a transformation ϕ on x, if x is not linearly separable. With the transformation, we move it to a higher dimensional space, in which the data becomes linearly separable.
Problem with this is: For polynomial features in high dimensions, ϕ becomes enourmous and feature construction thus computationally impossible.

→ Solution: Kernel Trick

92
New cards

What is the Kernel Trick?

Key Insight: We only need dot products <ϕ(x),ϕ(y)> in feature space. We define Kernel Functions K(x,y) = <ϕ(x),ϕ(y)> that replaces computation in feature space.

93
New cards

What is the goal of the kernel trick?

To learn nonlinear models without explicitly computing huge nonlinear feature vectors

94
New cards

What is a kernel?

A kernel is a function:

k(x,z)

that computes an inner product in feature space:

k(x,z)=⟨ϕ(x),ϕ(z)⟩

without explicitly computing ϕ(x).

95
New cards

What is the kernel matrix?

The kernel matrix K contains all pairwise kernel values between training points:

Kij=k(xi,xj)

96
New cards

What are the three steps of kernelization?

knowt flashcard image
97
New cards

Express model f with Kernel Matrix:

Before: f(x) = ∑​i=1,…,n α_i*​K(xi​,x)
Now: f(X) = Kα

98
New cards

Goals for nonlinear functions:

  1. More expressivity: We want functions that can fit most data

  2. Computational Efficiency: No explicit computation and storage of ϕ

  3. Convex Optimization: Then optimization is easier and more reliable

99
New cards

Example Kernel Functions:

  1. Linear Kernel: k(x,z) = x^Tz → corresponds to original feature space ϕ(x) = x

  2. Polynomial Kernel: k(x,z) = (1 + x^Tz)^m → corresponds to polynomial features up to degree m

  3. RBF/Gaussian Kernel: k(x,z) = exp(- (||x - z||²)/tau) → corresponds to a very rich, infinite dimensional feature space (tau = bandwidth parameter)

100
New cards

Nonlinear Regression vs. Kernelized Regression

knowt flashcard image