machine learning: part 2

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

1/198

encourage image

There's no tags or description

Looks like no tags are added yet.

199 Terms

1
New cards

what is the difference between classification and regression?

both are supervised learning problems, but they predict different types of outputs

  • classification: predict a discrete category

  • regression: predict a continuous numerical value


2
New cards

what do we use when the target we want to predict is numerical?

linear regression

3
New cards
<p>what is linear regression actually trying to learn? and how? </p>

what is linear regression actually trying to learn? and how?

unknown relationship between input variables and a numerical output

  • y = f (x) + ε


but we do not know f(x) so we construct a function ŷ(x) which approximates it using training data

<p>unknown relationship between input variables and a numerical output </p><ul><li><p>y = f (x) + <strong>ε</strong></p></li></ul><p></p><p>but we do not know f(x) so we construct a function <strong>ŷ</strong>(x) which approximates it using training data </p>
4
New cards

why do we include the noise term ε when describing the relationship between input and outputs?

  • real-world observations rarely follow a perfectly predictable relationship

  • noise term represents variation our model does not explain


5
New cards

does linear regression require the relationship between x and y to be a straight line?

no: linear regression means linear in the weights, not necessarily linear in the input

6
New cards

give an example of what ‘linear in the weights’ means?

  • this produces a curved relationship because of x²

  • the weights (w0, w1,w2) however only appear as coefficients so the model is still linear in the weights


<ul><li><p>this produces a curved relationship because of x² </p></li><li><p>the weights (w<sub>0</sub>, w<sub>1</sub>,w<sub>2</sub>) however only appear as coefficients so the model is still linear in the weights</p></li></ul><p></p>
7
New cards

what do the weights w0 and w1 represent in simple linear regression?

  • w0 is the intercept. the predicted value when x = 0

  • w1 is the slope. how much the prediction changes when x increases by one unit.


<ul><li><p> w<sub>0 </sub>is the intercept. the predicted value when x = 0</p></li><li><p> w<sub>1 </sub>is the slope. how much the prediction changes when x increases by one unit. </p></li></ul><p></p>
8
New cards

what is the residual in linear regression?

the difference between an observed target and the model’s prediction

  • ri = yi - ŷi

  • yi : actual observed value

  • ŷi : predicted value


9
New cards

what does ordinary least squares do (words)?

find the minimum-MSE fit by minimising the quadratic cost

10
New cards

why does ordinary least squares, square the residuals rather than simply adding them?

  1. positive and negative errors cannot cancel each other out

  2. large errors are penalised more strongly than small errors

  3. the resulting cost is a quadratic function of the weights, making optimisation mathematically convenient


11
New cards

what does ordinary least squares do (equation)?

knowt flashcard image
12
New cards

why do we differentiate the least -squares cost function?

  • want to find the weights that minimise prediction error


13
New cards

what does differentiating with respect to each weight tell us about a cost function?

how much changing that weight affects the cost

14
New cards

what are the normal equations in linear regression?

  • a system of equations used to find model parameters that minimise the sum of squared errors


15
New cards

how are the normal equations derived in linear regression?

  • taking partial derivatives of the sum of squared errors, with respect to each model parameter

  • set these to 0

  • rearrange to form a system of equations


<ul><li><p>taking partial derivatives of the sum of squared errors, with respect to each model parameter</p></li><li><p>set these to 0 </p></li><li><p>rearrange to form a system of equations </p></li></ul><p></p>
16
New cards

what does solving the normal equations in linear regression give?

the best fitting weights

17
New cards

why do we write using matrix notation for the normal equation?

  • more complicated regression models contain many weights

  • writing and solving separate equation for every weight becomes cumbersome

  • matrix notation allows us to represent all the equations together


18
New cards

the normal equation

  • describes the same, simple least-squares problem but works for any number of fixed features


<ul><li><p>describes the same, simple least-squares problem but works for any number of fixed features </p></li></ul><p></p>
19
New cards

what is the basis function Φi(x) in linear regression?

mathematical function that transforms an input into a feature used by the model

20
New cards

how does a model how much importance to assign to each feature?

weights

21
New cards

why do we need basis function instead of always using the original input space x?

allows the model to fit curved relationships while keeping the weights linear

22
New cards

what is the differnece between Φj(x) and Φ(x)?

Φj(x): one transformed feature

Φ(x): all transformed features grouped into a vector

23
New cards

when is the basis function chosen during training?

  • we are working with fixed-basis framework

  • and so the basis function is chosen in advance


24
New cards

why can polynomial regression be nonlinear in x but still count as linear regression?

knowt flashcard image
25
New cards

what is the design matrix Φ in linear regression?

a matrix containing the transformed features for every training observation


26
New cards

what does each row of the design matrix Φ represent?

one training example

27
New cards

what does each column of the design matrix Φ represent?

one basis function

28
New cards

the design matrix Φ.

knowt flashcard image
29
New cards

what are the dimensions of the design matrix Φ ?

  • M features (exc. bias term)

  • N training examples


<ul><li><p>M features (exc. bias term)</p></li><li><p>N training examples </p></li></ul><p></p>
30
New cards

what does the design matrix Φ allow?

all the training predictions to be calculated together

<p>all the training predictions to be calculated together </p>
31
New cards
<p>why can all regression predictions be written as: ? </p>

why can all regression predictions be written as: ?

  • each row of Φ (design matrix) contains features for one observation

  • multiply that row by w, calculates the weighted sum

  • matrix multiplication does this simultaneously for every row


<ul><li><p>each row of <strong>Φ </strong>(design matrix) contains features for one observation </p></li><li><p>multiply that row by w, calculates the weighted sum </p></li><li><p>matrix multiplication does this simultaneously for every row </p></li></ul><p></p>
32
New cards

how does the design matrix allow us to express the least squares cost using one equation?

knowt flashcard image
33
New cards

how does differentiating the matrix least-squares cost produce the normal equation?

knowt flashcard image
34
New cards
<p>what significance is given by the fact that if you differentiate the least-squares cost then you are lead to the normal equation? </p>

what significance is given by the fact that if you differentiate the least-squares cost then you are lead to the normal equation?

  • means that solving the normal equation is equivalent to finding weights that minimise the squared error


35
New cards
<p>what does the normal equation do for the least-squares solutions? </p>

what does the normal equation do for the least-squares solutions?

characterises them

<p>characterises them </p>
36
New cards
<p>what does the ordinary least-squares solution represent? </p>

what does the ordinary least-squares solution represent?

  • gives the weight vector that minimises the squared residuals

  • directly, rather than repeatedly updating the weights


37
New cards

what does the least-squares being convex show?

any minimum found is a global minimum

  • setting the gradient to 0 obtains a global minimiser of the least-squares cost


<p>any minimum found is a global minimum </p><ul><li><p>setting the gradient to 0 obtains a global minimiser of the least-squares cost </p></li></ul><p></p>
38
New cards

what does the least-squares being convex not show?

does not guarantee that the minimiser is unique

39
New cards

when does the design matrix Φ to have full column rank?

when every column of Φ is linearly independent of the others

  • no feature column can be constructed a linear combinations of the remaining columns


40
New cards

what does Φ having full rank ensure?

knowt flashcard image
41
New cards
<p>what is this? </p>

what is this?

pseudoinverse

  • generalises the idea of a matrix inverse

  • using this in the least-squares solution means that the equation works even when Φ is rank deficient


<p>pseudoinverse </p><ul><li><p>generalises the idea of a matrix inverse</p></li><li><p>using this in the least-squares solution means that the equation works even when <strong>Φ </strong>is rank deficient </p></li></ul><p></p>
42
New cards
<p>how is a minimiser chosen in rank deficient cases? </p>

how is a minimiser chosen in rank deficient cases?

  • can have multiple solutions

  • if so, choose the one with the smallest weight norm: ||w||2


43
New cards

underfitting vs overfitting.

  • underfitting: model too simple to capture underlying relationship

  • overfitting: model is excessively flexible and fits noise/ accidental patterns in training observations


44
New cards

what is a hypothesis set (ℋ) in machine learning?

collection of candidate prediction functions that a learning algorithm is allowed to choose from

45
New cards

hypothesis set for fixed-basis functions

knowt flashcard image
46
New cards

what is mean squared error?

averaged squared prediction error.

<p>averaged squared prediction error. </p>
47
New cards

how does mean squared error related to ordinary least squares?

knowt flashcard image
48
New cards

why doesn't low training error guarantee that a model has learnt the true underlying function?

  • training error is measured against observed targets, which contain noise, rather than the unknown true function.

  • a model can achieve low training error by fitting the noise instead of learning the true relationship (overfitting).


49
New cards

what is gradient descent?

an iterative optimisation algorithm that adjusts model parameters to reduce a cost function

50
New cards

gradient descent update rule.

knowt flashcard image
51
New cards

what does gradient descent do differently to OLS?

rather than solving directly, gradient descent approaches a minimum through repeated updates to find the optimal weights

52
New cards

why does gradient descent move in the negative gradient direction?

  • gradient points in the direction of steepest local increase of a differentiate function

  • negative gradient points in the direction of steepest local decrease

  • subtraction moves the weights downhill on the cost surface


53
New cards

what does the learning rate η control in gradient descent?

how far the weights move during each update

  • small: potentially slow convergence

  • excessively large: may overshoot and cause oscillation or divergence


54
New cards

how id gradient descent update rule applied specifically to linear regression?

  • by substituting the least-squares cost gradient into the gradient descent update rule

  • this repeatedly adjusts the weights according to the current prediction errors


<ul><li><p>by substituting the least-squares cost gradient into the gradient descent update rule </p></li><li><p>this repeatedly adjusts the weights according to the current prediction errors </p></li></ul><p></p>
55
New cards

OLS using the normal equation vs OLS using gradient descent.

both minimise the same least-squares objective

  • normal equation: directly using linear algebra

  • gradient descent: start with initial weights and repeatedly update them using gradient descent


with a suitable learning rate and sufficient convergence, gradient descent approaches a least-squares minimiser

56
New cards

why can OLS and gradient descent produce the same fitted line?

  • both optimise the same cost function R(w)

  • so both methods may approach the same weights


<ul><li><p>both optimise the same cost function R(w)</p></li><li><p>so both methods may approach the same weights </p></li></ul><p></p>
57
New cards

examples of basis functions.

knowt flashcard image
58
New cards

why do we need a probabilistic interpretation of what a regression function is?

  • ordinary regression finds a function that fits observed data

  • real observations come with noise and different functions may represent the same small data set


  • a probabilistic model allows us to describe how likely different observations are under a proposed regression function

  • give us a principled way to choose model parameters and understand what the fitted function represents


59
New cards

parameter uncertainty vs observation noise.

  • parameter uncertainty: we do not know the exact parameters describing the underlying relationships

  • observation noise: individual outputs vary randomly around the underlying mean relationship


60
New cards

why does collecting more data reduce parameter uncertainty?

  • each data point provides additional information about the underlying relationship

  • this constraints which parameter values are plausible, so estimates of the regression function become more precise


61
New cards

why does collecting more data not observation noise?

random variation affecting individual observations still exists

62
New cards
<p>what does this mean? </p>

what does this mean?

conditional probably distribution

  • the distribution of possible outputs y, given a particular input x

  • instead of one guaranteed value of y, it describes how the possible scores are distributed


63
New cards

how are p(x), p(x|y) and p(x, y) related?

knowt flashcard image
64
New cards
<p>why is this important for regression? </p>

why is this important for regression?

  • regression aims to predict outputs from known inputs

  • so we are interested in what values y may take, for a given x


65
New cards

frequentist approach to unknown parameters?

  • the true parameter θ is fixed, but unknown

  • and estimated from data

  • different data sets can produce different parameter estimates


66
New cards

bayesian approach to unknown parameter?

  • a probability distribution represents uncertainty about θ

  • when new data arrives, the distribution is updated


67
New cards
<p>what does this mean? </p>

what does this mean?

the probability of the data under a specified parameter value

  • D: the observed data set

  • θ: the unknown parameter of the model


<p>the probability of the data under a specified parameter value </p><ul><li><p>D: the observed data set </p></li><li><p>θ: the unknown parameter of the model </p></li></ul><p></p>
68
New cards

what is bayes’ rule?

updates our beliefs about unknown parameters using new evidence

69
New cards
<p>what does this mean when we are trying to learn θ?</p>

what does this mean when we are trying to learn θ?

  • p(θ|D): Posterior - updated uncertainty about parameters after observing data

  • p(D|θ): Likelihood- how well a parameter value explains the observed data

  • p(θ): Prior- uncertainty about parameters before observing the data

  • p(D): Evidence- normalises the posterior (D is the data we have observed)


<ul><li><p>p(θ|D): Posterior - updated uncertainty about parameters after observing data</p></li><li><p>p(D|θ): Likelihood- how well a parameter value explains the observed data</p></li><li><p>p(θ): Prior- uncertainty about parameters before observing the data</p></li><li><p>p(D): Evidence- normalises the posterior (D is the data we have observed)</p></li></ul><p></p>
70
New cards

what is the fundamental ideal behind bayes’ rule?

knowt flashcard image
71
New cards

what is the evidence for bayes’ rule in discrete parameters?

knowt flashcard image
72
New cards

what is the evidence for bayes’ rule in continuous parameters?

knowt flashcard image
73
New cards

bayes’ rule broken down: what did we believe before seeing the data?

knowt flashcard image
74
New cards

bayes’ rule broken down: how well does each possible parameter value explain the observed data?

knowt flashcard image
75
New cards

bayes’ rule broken down: what should we believe now, after considering the data?

knowt flashcard image
76
New cards

why do we multiply the prior by the likelihood in Bayesian inference?

  • prior: describes which parameter values were plausible before observing the data

  • likelihood: describes how compatible each parameter value is with the data we actually observed


  • multiplying them gives greater to parameter values *that are supported by both*


77
New cards

p(D) necessary in bayes’ rule?

  • multiplying the prior and likelihood does not generally produce a distribution that sums/ integrates to 1

  • dividing by this quantity ensures the posterior is properly normalised

  • (see calculation of P(D) and what the numerator of bayes’ rule is)


78
New cards

why can we ignore p(D) when finding a parameter value that maximises the posterior?

  • p(D) is constant and doesn’t depend on θ

  • dividing every score by the same constant doesn’t change which gives the highest value

  • therefore this is true:


<ul><li><p>p(D) is constant and doesn’t depend on θ</p></li><li><p>dividing every score by the same constant doesn’t change which gives the highest value </p></li><li><p>therefore this is true: </p></li></ul><p></p>
79
New cards

what is a likelihood function?

measures how well different parameter values explain the observed data


80
New cards

what do we keep fixed in a likelihood function?

  • keep data, D, fixed

  • change θ, to find which parameter value best explains it


81
New cards

what is the difference between a sampling model and a likelihood function?

both use the expression P(D | θ)

  • sampling: fixes the parameters θ and considers what data could be generated

  • likelihood: fixes the observed data and considers which parameter best explains it


82
New cards

what is maximum likelihood estimation (MLE)?

chooses the parameter value under which the observed data has the highest likelihood

  • θ: candidate parameter values

  • D: observed data set

  • arg max: find teh input that produces the largest value


<p>chooses the parameter value under which the observed data has the highest likelihood </p><ul><li><p>θ: candidate parameter values </p></li><li><p>D: observed data set</p></li><li><p>arg max: find teh input that produces the largest value </p></li></ul><p></p>
83
New cards

does MLE produce a probability distribution over the unknown parameters?

no

  • mle produces a point estimate: one parameter value (or set of maximisers if the optimum is not unique)


84
New cards

what does MLE not describe?

the full uncertainty surrounding the parameters

85
New cards

what is a gaussian distribution?

a continuous probability distribution with a bell shaped density curve

<p>a continuous probability distribution with a bell shaped density curve  </p>
86
New cards

how is the gaussian distribution curve written?

knowt flashcard image
87
New cards
<p>why does the gaussian density contain (x-μ)²? </p>

why does the gaussian density contain (x-μ)²?

knowt flashcard image
88
New cards

what is a multivariate gaussian distribution?

describes the joint behaviour of several variables.

<p>describes the joint behaviour of several variables. </p>
89
New cards

what does the covariance matrix Σ represent?

  • diagonal entries: the variance of each variable

  • off diagonal: how two variables vary together


<ul><li><p>diagonal entries: the variance of each variable </p></li><li><p>off diagonal: how two variables vary together </p></li></ul><p></p>
90
New cards

multivariate gaussian density.

knowt flashcard image
91
New cards

in the covariance matrix Σ, what does positive covariance mean?

they tend to increase or decrease together

92
New cards

in the covariance matrix Σ, what does negative covariance mean?

they tend to move in opposite directions

93
New cards

why do we need a covariance matrix Σ?

  • A single variance measures how much one variable varies.

A covariance matrix captures:

  • Variance: How much each variable varies individually.

  • Covariance: How different variables change together (like, height and weight).

This allows us to model relationships between multiple variables

94
New cards

why does independence allow us to multiply individual probability densities to calculate the likelihood?

  • independence means that knowing one observation does not change the distribution of another

  • so we can multiply and their joint density factorises

  • to produce a likelihood for the entire set


<ul><li><p>independence means that knowing one observation does not change the distribution of another </p></li><li><p>so we can multiply and their joint density factorises </p></li><li><p>to produce a likelihood for the entire set </p></li></ul><p></p>
95
New cards

what are we trying to estimate when applying MLE to Gaussian data?

  • find the mean μ vector and covariance matrix Σ that maximise the likelihood of the observed data

  • MLE finds the value that best explains the observations under the assumed gaussian model


96
New cards

what does mean μ represent in a gaussian distribution?

where the data is centred

97
New cards

what does covariance matrix Σ represent in a gaussian distribution?

its spread and the relationship between variables

98
New cards

why do we take the logarithm of the likelihood when performing MLE?

  • the likelihood of independent observations is a product

  • products can be difficult to differentiate and can become extremely small

  • taking log makes it a sum which is

    • easier to differentiate

    • more numerically stable


<ul><li><p>the likelihood of independent observations is a product </p></li><li><p>products can be difficult to differentiate and can become extremely small  </p></li><li><p>taking log makes it a sum which is </p><ul><li><p>easier to differentiate </p></li><li><p>more numerically stable </p></li></ul></li></ul><p></p>
99
New cards

why are we allowed to take logs of the likelihood when performing mle?

  • logarithm is a strictly increasing function

  • maximising the log-likelihood gives exactly the same parameter values as maximising the original likelihood


<ul><li><p>logarithm is a strictly increasing function </p></li><li><p>maximising the log-likelihood gives exactly the same parameter values as maximising the original likelihood </p></li></ul><p></p>
100
New cards

sample mean of the gaussian mle.

  • why does maximising a Gaussian likelihood give the sample mean as the estimated mean?


the likelihood is maximised when the estimated mean equals the average of the observations

<p>the likelihood is maximised when the estimated mean equals the average of the observations</p>