Introduction to Machine Learning - Mock Exam 1
Questa pagina non ha ancora la versione ripasso: qui sotto c'è il testo completo.
In questa pagina 14
The written tests of this course are not public. This mock exam is therefore built only on the notes of the course (learning and data, statistical learning framework, Hoeffding bound, perceptron and its convergence bound, ADALINE, logistic regression, nearest neighbour, linear regression, classification metrics, model selection, and the Python notebooks). The questions and the data are new: it is not a copy of any real test. The official format, from the course description, is continuous activities on the course platform and a final closed-book written test. The format used here is a proposal of this site, not declared by the course: 10 multiple-choice questions worth 1.5 points each and 3 problems worth 5 points each, for a total of 30 points, in 90 minutes, with four options per question and exactly one correct option.
Conventions used in the whole test: every input vector contains the constant coordinate , so and ; labels are for the perceptron and for logistic regression; is the natural logarithm.
How to use it: work with a timer, write each formula in letters before putting the numbers in, and look at the "Result" only when a question is finished.
Question 1
A discussion about a risk-scoring system says: "a machine-learning algorithm is just a complex formula, and a formula such as cannot be racist or sexist". Which conclusion does the course draw?
- A) The formula cannot be biased, because it is only mathematics, whatever the data are.
- B) A hypothesis learned from data inherits what is in the data: if is biased, then is biased too.
- C) The quality of the answer depends only on the formula, not on how the data were collected.
- D) In the case study, the defendant given the high risk score (8) went on to commit further offences.
Show the result
B
Show the full solution
B is correct: the reply quoted in Introduction to Machine Learning - Learning, Data and TasksMachine learning builds a hypothesis g that approximates an unknown target function f using only a set of historical examples (input, output). The course lecture frames learning as adaptive behaviour, shows through the credit-approval example the components of learning (input x, output y, target f, data, hypothesis g, hypothesis set, learning algorithm) and warns that a model is only as unbiased as its data. Tasks named in the course are classification and regression, supervised and non-supervised problems.Introduction to Machine Learning - Learning, Data and Tasks → is "if is biased, then will be biased too", and the consequence stated there is that a hypothesis learned from data inherits whatever is in the data. A is the claim that the reply rejects. C is false: the note says the quality of the answer depends on how the data were collected, not only on the formula. D is false: in the case study the defendant rated high risk (score 8) had no subsequent offences.
Question 2
Four samples are given: , , , . The hypothesis is and the error function is the squared difference. What is the in-sample error ?
- A)
- B)
- C)
- D)
Show the result
D
Show the full solution
The differences are , , , . Their squares are , , , , with sum (SSE) , and the in-sample error of The Statistical Learning Framework and Empirical Risk MinimizationA hypothesis is judged by an error function computed pointwise on the data and averaged: the in-sample (empirical) error E_in(h) = (1/N) sum of e(f(x_i), h(x_i)); with squared differences it is the sum of squared errors. The learning algorithms of the course all search the hypothesis set for the h with small in-sample error, but what matters is the error on new inputs drawn from the same input distribution, so the data must cover the regions where the inputs live, and part of the data must be held back to check the result.The Statistical Learning Framework and Empirical Risk Minimization → is the average over the points:
So D is correct. A is the sum of squares without the factor . B is the mean of the absolute values : the notes mention the absolute value as one possible way to make errors non-negative but choose the square. C is the mean of the signed differences, : signed differences cancel, which is why they are not a good measure.
Question 3
A hypothesis is fixed before looking at the data. Its in-sample error is measured on independent samples. Using the Hoeffding inequality of the course for one fixed hypothesis, which is the upper bound for ?
- A)
- B)
- C)
- D)
Show the result
A
Show the full solution
For one fixed hypothesis the inequality of PAC Learning and Hoeffding's InequalityFor a finite hypothesis set of M hypotheses and N independent samples, the probability that the in-sample error of the chosen hypothesis g differs from its true error by more than epsilon is at most 2 M exp(-2 epsilon^2 N). The bound comes from Hoeffding's inequality for one hypothesis, P(|nu - mu| > epsilon) <= 2 exp(-2 epsilon^2 N), and from the union bound P(E1 or ... or EM) <= P(E1) + ... + P(EM), which is exact only for disjoint events and loose when the bad events overlap.PAC Learning and Hoeffding's Inequality → is , with and . Here , so the bound is : A is correct. B drops the factor in front of the exponential. C uses in the exponent, forgetting that is squared. D uses , forgetting the factor in the exponent.
Question 4
A test object must be classified by K-nearest neighbour with and a plain majority vote (all neighbours count the same). The distances from the test object to the seven training objects, with their classes, are: (B), (A), (B), (A), (A), (C), (C). Which class is predicted?
- A) Class B, the class of the nearest object.
- B) Class C, the class of the two farthest objects.
- C) Class A.
- D) There is a tie between A and B, so no class is predicted.
Show the result
C
Show the full solution
The test phase of Nearest NeighbourK-nearest neighbours (KNN) has an almost empty training phase (the data are just stored) and does all the work at test time: given a point, compute its distance from all training points, sort the distances, keep the K shortest and predict the (weighted) majority class among them. The course source has one handwritten page on it; the notebooks use it as one of six scikit-learn classifiers, and the model-comparison example contrasts KNN with K=1 and K=5.Nearest Neighbour → is: compute the distances from all the training points (here they are given), sort them, keep the first elements, predict by the majority of their classes. The distances are already in increasing order, and the first five are (B), (A), (B), (A), (A): three votes for A and two for B, so the prediction is A and C is correct. A is the answer for and for (B, A, B), but not for : the value of is a hyper-parameter and changes the prediction. B uses the two farthest objects, which the algorithm discards. D is false: against is not a tie.
Question 5
In the course notes, what does the evaluation of a classifier consist in?
- A) The actual output is given by the hypothesis and the predicted output by the target ; they are compared on new objects.
- B) The vector of the actual outputs, given by the target , is compared with the vector of the predicted outputs, given by the hypothesis , on the same objects.
- C) The weight vector of one hypothesis is compared with the weight vector of another, without using any object.
- D) Binary versus multi-class and single-label versus multi-label are the same distinction, and the notes develop the multi-label case.
Show the result
B
Show the full solution
B is correct, as in Classification Metrics - Confusion Matrix, Precision, Recall and F1The performance of a classifier is read from the confusion matrix, whose rows are the actual classes and columns the predicted ones: TP, FN / FP, TN for a binary problem. Accuracy = (TP + TN) / total; recall = TP / (TP + FN); precision = TP / (TP + FP); F1 = 2 recall precision / (recall + precision). With an unbalanced data set accuracy can look good while recall is poor (10 positive and 90 negative objects: accuracy 0.87, recall 0.10, precision 0.20). In multi-class problems the confusion matrix is square and recall and precision are computed class by class from the diagonal.Classification Metrics - Confusion Matrix, Precision, Recall and F1 →: the target function gives the actual output, the hypothesis gives the predicted output, and evaluating a classifier means comparing the two on the same objects. A swaps the roles of and . C is false: the comparison is between outputs on objects, not between weights. D is false: the notes list single-label versus multi-label as another distinction beside binary versus multi-class, and say that the material that follows is single-label.
Question 6
Which description of the final procedure of the course for choosing a model (the letter-recognition example) is correct?
- A) Run k-fold cross-validation on the whole data set, choose the best model and report its cross-validation score; no separate test set is kept.
- B) Keep a test set of 20% of the data, score each of the six models on it, choose the best model from the test scores and then retrain it.
- C) Keep a test set, run cross-validation on the training set, choose the best model and evaluate it on the test set after each fold.
- D) Keep a stratified test set of 20% of the data untouched, run cross-validation on the training set only, compare the best models with a statistical test, train the chosen model on the whole training set and evaluate it once on the test set.
Show the result
D
Show the full solution
D is the procedure of Model Selection and Validation - Hold-Out, k-Fold and Statistical TestsTo decide which of two models is better, fix their hyper-parameters, train each on a training set (this fits the parameters, the vector w or theta) and measure a performance score such as F1 on a separate test set; one split is too fragile, so the hold-out is repeated K times (or K-fold cross-validation is used) and the paired scores of the two models are compared with a statistical test. The null hypothesis H0 is that the two models perform equally; the significance level alpha is fixed before the experiment, and the p-value is the probability of observing the obtained differences under H0. Parametric test: t-test; non-parametric: Wilcoxon.Model Selection and Validation - Hold-Out, k-Fold and Statistical Tests → (section on the final notebook, code in Python Notebooks - scikit-learn Model Comparison and Wilcoxon TestTwo example notebooks compare six scikit-learn classifiers (logistic regression, perceptron, KNN, decision tree, SVC, random forest) on a real data set loaded from the UCI repository: hold-out split with train_test_split, F1 score, k-fold cross-validation with cross_validate and scoring f1_macro, box plots of the fold scores, and the Wilcoxon signed-rank test (scipy.stats.wilcoxon) on the paired fold scores; the second notebook adds a stratified test set, more folds on the best models and the final training and test of the chosen model. A separate short notebook draws two normal samples to see how often the Wilcoxon test rejects at the 0.05 level.Python Notebooks - scikit-learn Model Comparison and Wilcoxon Test →): the test set is held out first and not touched until the end; k-fold cross-validation runs on the training set only; the best models are compared with the Wilcoxon test; the chosen model is trained on the whole training set and evaluated once on the test set. A is wrong because it keeps no test set. B is wrong because the test set is not used to choose the model. C is wrong because the test set is used once, at the end, not after each fold.
Question 7
A perceptron has weights on the features . As in the course notebooks, its boundary is drawn in the plane as the line . What are and ?
- A) ,
- B) ,
- C) ,
- D) ,
Show the result
A
Show the full solution
From we get (see Halfspaces and the Perceptron AlgorithmA perceptron computes h(x) = sign(w^T x) where x includes a constant coordinate x0 = 1 that absorbs the threshold into the bias weight w0; its decision boundary is the hyperplane w^T x = 0 (a line in the plane, x2 = -(w1/w2) x1 - w0/w2). The Perceptron Learning Algorithm scans the data and, on every misclassified point, replaces w by w + y x. A single perceptron cannot separate the exclusive-or pattern; two perceptrons feeding a third give a multilayer network.Halfspaces and the Perceptron Algorithm →; the notebook Python Notebooks - Perceptron and ADALINE from ScratchCode of the course notebooks that implement the Perceptron Learning Algorithm first with Python lists, then with plots of the successive lines, then with NumPy arrays (data matrix X with a column of ones, update w + eta * y * x on mistakes, epoch counter), and finally ADALINE: batch gradient descent with delta_w = eta * 2 * X^T (y - X w) / N and the stochastic version that shuffles the data and updates after every example. Differences between the versions (condition for a mistake, learning rate, stopping rule) are pointed out.Python Notebooks - Perceptron and ADALINE from Scratch → draws the line with exactly this formula). With the data: slope and intercept , so A is correct. B has both signs wrong. C uses for the slope. D uses instead of for the intercept.
Question 8
A data set has the labels y = [1, 2, 3, 2, 1, 3]. To train a binary classifier for one class, the exercise notebook runs
positive_class = 2
y_class = -np.ones(y.shape[0])
y_class[y == positive_class] = 1What is the vector y_class?
- A)
[1, -1, -1, -1, 1, -1] - B)
[0, 1, 0, 1, 0, 0] - C)
[-1, 1, -1, 1, -1, -1] - D)
[1, 1, -1, 1, 1, -1]
Show the result
C
Show the full solution
The vector is first filled with and then the entries where y equals positive_class become : the labels equal to are in positions 2 and 4, so y_class = [-1, 1, -1, 1, -1, -1] and C is correct. This is the "class against the rest" reduction of Python Notebooks - Exercises on Perceptron, Regression and Logistic RegressionThe exercise notebooks of the course: generating two- and three-class data with NumPy distributions, training an ADALINE/perceptron by mini-batch stochastic gradient descent and plotting the errors per epoch, polynomial regression by the closed form w = (X^T X)^{-1} X^T y on a data matrix with columns 1, x, x^2, and logistic regression trained by mini-batch gradient descent on the log loss. Statement and solution code are given, with the inconsistencies between statement and code pointed out.Python Notebooks - Exercises on Perceptron, Regression and Logistic Regression →, with labels . A marks the class as positive. B uses the coding, which the perceptron exercise does not use: the other objects get . D marks the classes and as positive, but only one class is positive.
Question 9
Which statement about creating strings in Python, as in the course notebook, is correct?
- A)
'a string' == "a string"isFalse, because the two strings are written with different quotes. - B) A triple-quoted string can span several lines, and its value contains the line breaks (shown as
\n). - C) The value of a triple-quoted string contains no line breaks: they are removed when the string is created.
- D) Single quotes are used for strings of one word and double quotes for strings that contain spaces.
Show the result
B
Show the full solution
B is correct: Python Notebooks - Strings and Regular ExpressionsNotebook on Python strings: quoting (single, double, triple quotes), case methods (upper, lower, title, capitalize, swapcase), removing characters at the ends (strip), searching and replacing (find, startswith, endswith, replace, partition), splitting (split, splitlines), and a first use of regular expressions with the re module (search, findall, sub) with the anchors for start and end of string, the dot, the star, the plus and character classes.Python Notebooks - Strings and Regular Expressions → shows a triple-quoted string on several lines whose value contains the line breaks. A is false: single and double quotes create the same string, so the comparison is True. C contradicts B. D is false: the notebook itself writes 'a string' with single quotes and a space inside.
Question 10
With import re and txt = "The rain in Spain", which call returns None?
- A)
re.search("rain", txt) - B)
re.search(".*pain", txt) - C)
re.search("[a-m]in", txt) - D)
re.search(".*spain", txt)
Show the result
D
Show the full solution
In Python Notebooks - Strings and Regular ExpressionsNotebook on Python strings: quoting (single, double, triple quotes), case methods (upper, lower, title, capitalize, swapcase), removing characters at the ends (strip), searching and replacing (find, startswith, endswith, replace, partition), splitting (split, splitlines), and a first use of regular expressions with the re module (search, findall, sub) with the anchors for start and end of string, the dot, the star, the plus and character classes.Python Notebooks - Strings and Regular Expressions → the search is case sensitive and the pattern .*spain has a lower-case s, while the text contains Spain: there is no match, so D returns None. A matches because rain is in the middle of the text. B matches from the start of the text up to pain (.* is any number of any characters). C matches because a character class [a-m] followed by in is found (a letter between a and m followed by in, here in rain and in Spain).
Problem 1 (points 5)
A perceptron is trained with the Perceptron Learning Algorithm starting from on the following four points, always scanned in this order:
| point | ||
|---|---|---|
A point is a mistake, and the update is made, whenever (the case included). The passes over the four points are repeated until a whole pass has no update.
a) Write every update (point used and weight vector after it) and give the number of updates and the number of passes (2 points).
b) Compute for the four points with the final and check that all of them are correct (0.5 points).
c) The unit vector separates the data. Compute the margin , the radius (with the coordinate included) and the bound (1.5 points).
d) Compare with the bound. What does the bound count, and does it depend on the number of points? (1 point)
Show the result
a) Updates: ; ; ; . updates, 3 passes (the third has no update). Final .
b) for : all positive.
c) , so ; (from ), ; .
d) . The bound counts updates, not passes; it depends only on and , not on the number of points or of features.
Show the full solution
Setting: Halfspaces and the Perceptron AlgorithmA perceptron computes h(x) = sign(w^T x) where x includes a constant coordinate x0 = 1 that absorbs the threshold into the bias weight w0; its decision boundary is the hyperplane w^T x = 0 (a line in the plane, x2 = -(w1/w2) x1 - w0/w2). The Perceptron Learning Algorithm scans the data and, on every misclassified point, replaces w by w + y x. A single perceptron cannot separate the exclusive-or pattern; two perceptrons feeding a third give a multilayer network.Halfspaces and the Perceptron Algorithm → for the update rule and Perceptron Convergence and the Margin BoundThe distance of a point x from the hyperplane w^T x + b = 0 is |w^T x + b| / sqrt(w^T w), obtained by writing x = x_p + gamma with gamma parallel to w. If the data are linearly separable with margin gamma (a unit vector w* with y_i w*^T x_i >= gamma for all i) and every point lies in a ball of radius R, the Perceptron Learning Algorithm makes at most K <= R^2 / gamma^2 updates. Proof: after K updates w_{K+1}^T w* >= K gamma, hence norm of w_{K+1} >= K gamma; and norm of w_{K+1} squared <= K R^2; combine.Perceptron Convergence and the Margin Bound → for the bound.
a) The run. Each point is the vector .
Pass 1.
- , , : , a mistake. .
- , , : , so , correct, no update.
- , , : , , a mistake. .
- , , : , correct.
Pass 2.
- : , so , a mistake (the case counts as a mistake, as in the proof of the bound). .
- : , , a mistake. .
- : , correct.
- : , correct.
Pass 3. : , ; : , value ; : ; : . No update: the algorithm stops with updates and .
b) Check. The values computed in pass 3 are , all positive: every point is on the correct side. The boundary is .
c) Margin and radius. With the unit vector (check: ) the products are:
- : ;
- : ;
- : ;
- : .
The smallest is . The squared norms of the vectors are , , , , so . The bound is
d) Comparison. The algorithm made updates, far below : the bound is only an upper limit that depends on the geometry (a small margin gives a large bound). It counts updates, not passes over the data (here the algorithm made 3 passes, the last one without updates), and it depends only on and , not on the number of points or of features.
Typical mistakes: not counting the value as a mistake (the run changes from the first step); updating on points that are already correct; forgetting the coordinate in the norms (then and the bound would be ); confusing the number of updates with the number of passes.
Problem 2 (points 5)
Five samples are given: , , , , . The data matrix has a first column of ones. The error is .
a) An ADALINE with the linear hypothesis starts from . Compute at this point (0.5 points).
b) Compute the gradient at , make one gradient-descent step with , and compute after the step (1.5 points).
c) Fit the quadratic hypothesis with the closed form : write the data matrix with the columns , the matrices and , and solve (2 points).
d) Compute of the quadratic fit and compare it with the values of parts a and b. What does the closed form guarantee that one gradient step does not? (1 point)
Show the result
a) .
b) ; ; ; .
c) , , , that is .
d) Fitted values ; SSE ; , much smaller than and than . The closed form gives the exact minimiser of in its hypothesis set (the matrix is invertible), while one step only moves part of the way.
Show the full solution
Setting: ADALINE and Gradient DescentADALINE is a perceptron whose activation function is the identity: during training the unit outputs w^T x and the in-sample error E_in = (1/N) sum (y_i - w^T x_i)^2 is minimised by gradient descent, w_new = w_old - eta * grad E_in, with partial derivatives dE_in/dw_j = (2/N) sum (y_i - w^T x_i)(-x_i^j) and matrix form grad E_in proportional to -X^T (Y - X w). The prediction is still the sign of w^T x. Learning rate eta sets the step size and a stopping rule ends the iteration.ADALINE and Gradient Descent → for parts a and b, Linear RegressionIn linear regression the hypothesis is h(x) = w^T x and the in-sample error is E_in(w) = (1/N) sum (w^T x_i - y_i)^2 = (1/N) times the squared norm of (Xw - Y), with X the N-row data matrix. Setting the gradient (2/N) X^T (Xw - Y) to zero gives the normal equations X^T X w = X^T Y and the closed-form solution w = (X^T X)^{-1} X^T Y, where (X^T X)^{-1} X^T is the pseudo-inverse of X; only a small square matrix (number of features) has to be inverted. Polynomial regression is the same formula on a data matrix with columns 1, x, x^2, ...Linear Regression → for parts c and d; the error is the one of The Statistical Learning Framework and Empirical Risk MinimizationA hypothesis is judged by an error function computed pointwise on the data and averaged: the in-sample (empirical) error E_in(h) = (1/N) sum of e(f(x_i), h(x_i)); with squared differences it is the sum of squared errors. The learning algorithms of the course all search the hypothesis set for the h with small in-sample error, but what matters is the error on new inputs drawn from the same input distribution, so the data must cover the regions where the inputs live, and part of the data must be held back to check the result.The Statistical Learning Framework and Empirical Risk Minimization →.
a) Starting error. At the output is for every sample, so the errors are the labels themselves:
b) One step. The data matrix is and . At the vector is itself, and
The gradient with the constant is . The rule gives
The new residuals are , , , , , and
The error went down from to : the step moves against the gradient, but it is still far from the minimum.
c) Closed form for the quadratic. The hypothesis is linear in the weights, so the data matrix gets the columns :
The sums of powers are , , , , so
The normal equations read , , . The second gives . From the first, ; in the third, , so and , . Hence and . (The matrix is invertible: its determinant is .)
d) Error of the fit. The fitted values are , , , , , with residuals , , , , . The SSE is and . This is much smaller than (start) and than (after one step). The closed form returns the exact minimiser of over the quadratic hypotheses in one shot, with the inversion of a matrix whose size is the number of columns (); gradient descent only approaches the minimum step by step and needs a learning rate and a stopping rule.
Typical mistakes: the sign of the update (the step is , that is without the constant); forgetting the column of ones or the column ; forgetting to divide by when computing (SSE instead of the average); using for a non-square matrix.
Problem 3 (points 5)
A logistic-regression classifier has with and weights . Seven objects have one feature and a label :
| object | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|
a) Compute and the probability of the positive class for each object (1 point).
b) Assign each object to a class (class when ), build the confusion matrix with the positive class , and compute accuracy, recall, precision and (1.5 points).
c) Compute the cost over the seven objects (1.5 points).
d) Make one gradient-descent step with , using with . Give the new weights and the new cost, and say whether the cost has decreased (1 point).
Show the result
a) ; .
b) Predicted classes . , , , . Accuracy ; recall ; precision ; .
c) Terms ; .
d) Gradient ; ; the new cost is : it has decreased.
Show the full solution
Setting: Logistic RegressionLogistic regression models the probability p of the positive class: the logit (log of the odds p/(1-p)) is assumed linear in the input, logit(p) = w^T x = z. Inverting it gives p = 1/(1 + e^(-z)), the logistic sigmoid; an object goes to class 1 when the sigmoid exceeds 0.5, i.e. when z > 0. The parameters are learned by maximising the Bernoulli log-likelihood, equivalently minimising the cost J = -y log(yhat) - (1 - y) log(1 - yhat), by gradient descent with gradient (1/m) X^T (h(x) - y).Logistic Regression → for the model, the cost and the gradient step; Classification Metrics - Confusion Matrix, Precision, Recall and F1The performance of a classifier is read from the confusion matrix, whose rows are the actual classes and columns the predicted ones: TP, FN / FP, TN for a binary problem. Accuracy = (TP + TN) / total; recall = TP / (TP + FN); precision = TP / (TP + FP); F1 = 2 recall precision / (recall + precision). With an unbalanced data set accuracy can look good while recall is poor (10 positive and 90 negative objects: accuracy 0.87, recall 0.10, precision 0.20). In multi-class problems the confusion matrix is square and recall and precision are computed class by class from the diagonal.Classification Metrics - Confusion Matrix, Precision, Recall and F1 → for part b.
a) Scores and probabilities. With the bias coordinate , :
| object | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|
For example .
b) Classes and metrics. The rule is the same as : objects go to class , objects to class . Comparing with the labels (rows actual, columns predicted):
Pred P Pred N
Actual P 3 2
Actual N 1 1- : objects ; : objects (actual , predicted ); : object ; : object .
- , , .
- .
c) Cost. For the term is , for it is (this is , the Bernoulli log-likelihood with the sign changed, see Bernoulli Distribution and Maximum Likelihood EstimationA binary outcome (heads = 1, tails = 0) is modelled by a Bernoulli distribution with parameter theta: P(x | theta) = theta^x (1 - theta)^(1 - x). For independent identically distributed observations the likelihood is the product of the single probabilities; with K heads in n tosses it is L(theta) = theta^K (1 - theta)^(n - K). Maximising the log-likelihood l(theta) = K log theta + (n - K) log(1 - theta) (maximum likelihood estimation) gives theta = K / n.Bernoulli Distribution and Maximum Likelihood Estimation →):
- object 1 (): ;
- object 2 (): ;
- object 3 (): ;
- object 4 (): ;
- object 5 (): ;
- object 6 (): ;
- object 7 (): .
The sum is (computed with unrounded probabilities).
d) One gradient step. The output errors are , , , , , , . The gradient components are
The update gives
With the new weights the cost is : it has decreased (and object now has , so it is assigned to class ).
Typical mistakes: using the logit instead of the probability; minimising instead of (sign of the cost); forgetting the factor in the gradient; adding the gradient instead of subtracting it; confusing precision with recall (swapping and in the denominators); mixing the coding with the coding.
Self-assessment grid
| item | points | what must be there for full points | typical mistakes |
|---|---|---|---|
| Question 1 | 1.5 | B: a hypothesis learned from data inherits the bias of the data | trusting the formula and ignoring how the data were collected |
| Question 2 | 1.5 | D: squared differences averaged over , | forgetting ; absolute values; signed differences |
| Question 3 | 1.5 | A: | dropping the 2; not squaring |
| Question 4 | 1.5 | C: five nearest neighbours, three A against two B | using or ; using the farthest objects |
| Question 5 | 1.5 | B: actual outputs of against predicted outputs of on the same objects | swapping and ; comparing weights |
| Question 6 | 1.5 | D: test set kept aside, cross-validation on the training set only, one final evaluation | choosing the model with the test set; no test set |
| Question 7 | 1.5 | A: , | wrong signs; swapping and |
| Question 8 | 1.5 | C: everywhere, where the label equals the positive class | coding; marking more than one class |
| Question 9 | 1.5 | B: triple quotes span lines and keep the line breaks | thinking single and double quotes differ |
| Question 10 | 1.5 | D: case-sensitive search, .*spain gives None |
ignoring the case; misreading the character class |
| Problem 1 | 5 | the four updates with the weights , , , and (2); check of the final (0.5); , , bound (1.5); comparison and meaning of the bound (1) | the value not counted as a mistake; no in the norms; updates confused with passes |
| Problem 2 | 5 | (0.5); gradient , , (1.5); , and (2); and the comparison (1) | wrong sign of the step; missing column ; SSE instead of the average |
| Problem 3 | 5 | and (1); confusion matrix and the four measures (1.5); (1.5); new weights, and the comment (1) | logit instead of probability; wrong sign of the cost; missing ; swapped and |
| Total | 30 |