Tutor knowledgeMachine LearningLLM Files / Knowledge Files107 KB
{0}------------------------------------------------
Consider a dataset with 2 objects per class and features. For the negative class, the objects are located at [0,0] and [-0.2,-0.1] and for positive class at [1,1.5] and [1,1]. Give the weight vector and the number of support vectors (SVs) that the support vector machine will find.
| SVs<br>How many support vectors are there? | weight: 1.0 |
|---|---|
| Select one option | Model Answer |
| [ ] 1 | |
| [x] 2 | |
| [ ] 3 | |
| [ ] 4 |
Model Answer
weight: 1.0
Image /page/0/Picture/7 description: The image shows a light blue speech bubble with an information icon on the left and the text "Nov 10 23:16:36" on the right.
{1}------------------------------------------------
Consider the following image that represents an image that is 8 pixels high and 24 pixels wide, where white pixels represent a value of 1 and black pixels a value of 0:
Image /page/1/Picture/2 description: The image shows the word "EXAM" in white letters on a black background. The letters are pixelated.
Suppose we apply a convolution on the image, using the following 3 by 3 kernel:
What will the maximum value in the convolved image be?
| Model Answer | |
|---|---|
| 0 | |
| 1 | |
| 2 |
{2}------------------------------------------------
Indicate which claim is TRUE
Model Answe
{3}------------------------------------------------
| Single linkage<br>In agglomerative clustering using single linkage, which of the following statements is <b>TRUE</b> ? | weight: 1.0 |
|---|---|
| Select one option | A Model Answer |
| It forms clusters based on the maximum pairwise distance between data points. | |
| It is less sensitive to outliers compared to complete linkage. | |
| It tends to produce elongated clusters. | |
| It is the fastest linkage method in terms of computational complexity. |
{4}------------------------------------------------
Image /page/4/Figure/1 description: The image shows a neural network diagram. The network has three input nodes labeled x0=1, x1, and x2. There are two hidden nodes labeled h1 and h2, and an output node labeled y-hat. There is also a bias node h0=1 connected to the output node. The connections between the nodes are represented by arrows, with associated weights. The weights are as follows: x0 to h1 is 0.5, x1 to h1 is -0.5, x2 to h1 is 0.5, x0 to h2 is -5, x1 to h2 is 1, x2 to h2 is 1, h0 to y-hat is 0, h1 to y-hat is -1, and h2 to y-hat is -1.
Consider the multilayer perceptron depicted in the figure, where the numbers next to the edges denote the weight of each connection. Suppose we use a logistic activation function for both the hidden nodes and the output node.
If the input to this model is what will the value for be?
♣ collapse Model An Select one option Explanation and SO:
weight: 1.0
{5}------------------------------------------------
The difference between the apparent error and the true error is called:
Select one option
Difference is overfitting, indicating that the predictor has learned the peculiarities of the training set and does not generalise well to new, unseen data.
weight: 1.0
Model Answer
{6}------------------------------------------------
Select one statement that is
{7}------------------------------------------------
Consider training a so-called "large language model" (for instance, a simplified ChatGPT). Our model needs to take in the previous word in a sentence and predict the next word. Suppose there are 30,000 unique words in our language, we have a training dataset of 5 million words, we train the model for 20 epochs and we use a learning rate of 0.001. How many classes does this classification problem have?
| Select one option | |
|---|---|
| <input checked="true" type="checkbox"/> 30,000 | |
| <input type="checkbox"/> 4,999,999 | |
| <input type="checkbox"/> 20 | |
| <input type="checkbox"/> 100,000,000 | |
| Model Answer |
{8}------------------------------------------------
Imagine a loan approval system that considers a person's credit score and their gender, among several factors for making loan decisions. In the context of this story, what would be the most appropriate action in fair machine learning?
Model Answer
weight: 1.0
☐ Include gender as a significant feature in the model to ensure equal representation.
☐ Ignore gender entirely and rely on other attributes for decision-making.
Utilize sensitive attributes like gender in the model but apply fairness-aware techniques to mitigate bias.
☐ Share gender information publicly for transparency in loan approval processes.
{9}------------------------------------------------
Rather than using the entropy to measure node impurity, in this assignment we are going to use the gini index in our splitting criterion to construct decision trees. If we let be the proportion of objects belonging to class in a set of objects , the Gini index is defined as:
Just like in the case of entropy, the gain in purity is given by:
where contains the indices of the subsets obtained after splitting, are the objects in the subset and indicates the number of objects in a set
labels is a numpy.ndarray that consists of labels corresponding to the objects. subsets is a numpy.ndarray that consists of the subset IDs of each object.
Note: In order to call the functions in your Solution class use: Solution.compute_gini_index(labels) and <pre>Solution.compute_gain(labels, subsets).</pre>
Given an array labels of 3 classes: <code>compute_gini_index</code> should return:
Given a division into <code>subsets</code> : (i.e., first object is in <code>subset</code> 0, etc.) <code>compute_gain</code> should return:
X Nov 10 '23 16:36
| Solution | Specification Test |
|---|---|
| 1 | import numpy as np |
| 2 | |
| 3 | |
| 4 | class solution(): |
| 5 | |
| 6 | def compute_gini_index(labels): |
| 7 |
{10}------------------------------------------------
Identify a FALSE statement about Naive Bayes.
Select one option
The Naive Bayes classifier using a Gaussian distribution per feature will always give a linear decision boundary.
Naive Bayes is not affected by feature scaling.
□ When training a Naive Bayes classifier you can choose to ignore an attribute for a data instance, where the attribute's value is missing.
<br> The Naive Bayes classifier does not model correlations between features.
Model Ansı
{11}------------------------------------------------
Layout: |||| 🔻
Consider the following definition of the logistic regression model: we try to find a function to predict the probability of a discrete label, by considering the class of linear functions mapped through a logistic function:
where
Suppose we denote the labels using and these labels can be either or We define the average negative log likelihood as:
We are interested in minimizing this average log likelihood.
Implement the following:
Hint: remember that the derivative of the logistic function is
For example inputs and corresponding outputs, see the two tests in the Test tab.
| Solution | Specification Test |
|---|---|
| 1 | import numpy as np |
| 2 | |
| 3 | class Solution(): |
| 4 | |
| 5 | import numpy as np |
| 6 | |
| 7 | class Solution(): |
| 8 | |
| 9 | def compute_nll(w, X, Y): |
| 10 | XT_w = w.T @ X.T |
| 11 | h_x = 1 / (1 + np.exp(-XT_w)) |
| 12 | log_likelihood = Y * np.log(h_x) + (1 - Y) * np.log(1 - h_x) |
| 13 | |
| 14 | return -1 * log_likelihood.mean(axis=0) |
{12}------------------------------------------------
When class priors change what statement is true about the decision boundary of the Linear Discriminant classifier?
The shape of the decision boundary cannot change, only the location can change.
Only the shape of the decision boundary can change, but not the location.
Both the shape and the location of the decision boundary cannot change.
Both the shape and the location of the decision boundary can change.
The decision boundary stays linear.
weight: 1.0
Model Answer
{13}------------------------------------------------
Which statement about PCA is false?
<br> The larger the number of principal components for PCA, the smaller the reconstruction error.
☐ Principal components found by PCA are always orthogonal.
Reducing the dimensionality using PCA must not be done as preprocessing step before applying a classification model.
weight: 1.0
Model Ansv
☐ Two principal components are ideal for visualization purposes using PCA.
{14}------------------------------------------------
Given a 1-dimensional training data set with four feature vectors. Two points are from the first class and are located at coordinates 0 and 2. The two other points are from the second class and are at 3 and 7. To solve the classification task, we use the nearest mean classifier.
Give the leave-one-out estimate for the true error rate.
A Model Arm
There are 4 situations Leave out 1. m1=2, m2=5, dec,boundary=3.5, error=0 Leave out 2: m1=0, m2=5, dec.boundary=2.5, error=0 Leave out 3: m1=1, m2=7, dec boundary=4, error=1 Leave out 4: m1=1; m2=3; dec boundary=2; error=0 or 0.5 or 1.0 So, in total an error of 0.25, 0.375 or 0.5
weight 1.0
A Model Announ
Assume now that the true class distributions is uniform between 0 and 4 for the first class and uniform between 3 and 8 for the second class. Given equal prior class probabilities, determine the true error the nearest mean classifier will attain using the above training set.
| The two class distributions are |
|---|
| , , so |
verge 10
A Model Armour
Calculate the difference between the true error rate the nearest mean classifier achieves and the Bayes error for this problem.
The decision boundary of the Bayes classifier is at That means that no error is made for class , but for class we get . The total error is therefore .
This error is therefore lower than that of the nearest mean.
{15}------------------------------------------------
Image /page/15/Figure/1 description: The image shows two probability density functions (pdfs) of two classes in a 1D feature space. The x-axis represents the feature space, and the y-axis represents the probability density. One pdf, labeled p(x|y1), is a triangle that starts at 1/2 on the y-axis when x is 0 and decreases linearly to 0 when x is 4. The other pdf, labeled p(x|y2), is a rectangle that starts at 1/4 on the y-axis when x is 0 and remains constant until x is 4.
Posterior probabilities
Assume that the class prior probabilities are and . Derive the posterior probability for class of .
weight: 1.0
Model Answer
weight: 1.0
weight: 1.0
Model Answe
Model An
For we see that and . Now, using Bayes rule, we obtain .
Decision boundary of Bayes classifier Where is the decision boundary of the Bayes classifier?
The decision boundary will be where the two pdfs, multiplied by the class priors, cross. That is where so at
Bayes error
How large is the Bayes error?
We need to compute the area of the two class errors. The error for class 1 is . Error on class 2 is . The total error – taking class priors into account – is
Image /page/15/Picture/11 description: The image shows a light blue speech bubble with an information icon on the left and the text "Nov 10 '23 15:36" on the right.
{16}------------------------------------------------
Assume we are applying a nested crossvalidation to optimise the hyperparameters of a classification model. We use 5-fold for the inner crossvalidation, and 10-fold for the outer crossvalidation. In total our dataset has 100 objects.
Which of the following statements is correct?
Select one option
The validation fold has 18 samples, and the test fold has 10 samples.
The validation fold has 5 samples, and the test fold has 10 samples.
☐ The validation fold has 10 samples, and the test fold has 10 samples.
The validation fold has 10 samples, and the test fold has 18 samples.
The outer crossvalidation determines the size of the test fold: That means that for training 90 objects are available.
The inner crossvalidation determines the size of the validation fold: .
weight: 1.0
Model Answe
{17}------------------------------------------------
Suppose I trained a linear logistic regression model with one feature. I denote this model as . Suppose we also know that = 0.3 and that What will the value for be?
Select one option
It's impossible to know based on the information given in the question.
It must be 0.5.
weight: 1.0
{18}------------------------------------------------
Consider splitting on a continuous feature during the training of a decision tree classifier. Which of the following is always true?
weight: 1.0
Model An
Select one option
Scaling the feature values has no effect on the information gain.
☐ If the same feature was already used to split in a higher node in the tree (closer to the root), using it again can never improve the tree.
The number of thresholds for the split we need to consider is quadratic in the number of objects in the node.
□ Splitting on a continuous feature will lead to higher information gain than splitting on a discrete feature.
{19}------------------------------------------------
Model Answer
Assume we want to train a classifier on a dataset having samples. In expectation, the average 10-fold crossvalidation error is (ANSWER) the true error for this classifier trained on samples.
(Fill in the (ANSWER))
Select one option
larger than
☐ smaller than
an unbiased estimator of
(none of the above: we cannot make a claim like this)
Because the classifier is trained with slightly less than samples each time in the crossvalidation, the error is, in expection, a bit worse than the true one.
{20}------------------------------------------------
Which of the following statements best characterizes the difference between normative and descriptive ethics?
Select one option
Descriptive ethics offers psychological accounts of how we ought to act, whereas normative ethics offers sociological accounts of how we ought to act.
Descriptive ethics offers explanations of, and factual statements about the moral systems people subscribe to, - how we act and understand ourselves as moral beings, while normative ethics offers prescriptive accounts on how we ought to act and understand ourselves as moral beings.
☐ Descriptive ethics offers a characterization of how others behave morally, while normative ethics characterizes how I behave morally.
☐ Descriptive ethics offers a characterization of how we ought to behave while normative ethics characterizes the norms that we as a matter of fact obey as members of society.
weight: 1.0
Model Answer
{21}------------------------------------------------
Suppose we trained a linear regression model on a dataset with a single feature , and we find parameters and . Consider the following two predictions of this model: and Which statement is true?
| Select one option | Model Answer |
|---|---|
weight: 1.0
{22}------------------------------------------------
Fill in the blank: In the empirical risk minimization framework, we minimise the empirical risk over all functions that are elements of the (ANSWER).
Select one option
Model Answer
weight: 1.0
Hypothesis class
Loss function
Maximum Likelihood
Gradient Descent
{23}------------------------------------------------
weight: 1.0
Suppose you work for an athletics company that offers an app used by 100,000 runners which tracks 15 different measures that describe their activity profile (such as, the number of minutes they run, their average speed, etc.). We want to find out what different types of runners exist, using machine learning on this data. What type of machine learning task is this?
Select one option A Model Answer
| Regression | |
|---|---|
| Classification | |
| Clustering | ☑ |
| Dimensionality Reduction |
{24}------------------------------------------------
Which of the statements is true ?
<br>K for KNN should be tuned by looking at the 2D plot of the decision boundary.
If a very large k is used for KNN, the classification boundary becomes simpler.
<br> K-NN is insensitive to feature scaling.
K-NN requires an explicit training step.
Model Answer
weight: 1.0
{25}------------------------------------------------
Which of the following statements is TRUE about back-propagation.
Backpropagation can be used during decision tree learning to propagate information from the leaves to the root of the tree
☐ Backpropagation tells us how to update the weights to improve the 0-1 loss (i.e. classification error)
Backpropagation helps efficiently calculate the gradient for the logistic regression model
Backpropagation requires both a "forward pass" and a "backward pass"
weight: 1.0
Model Ans
{26}------------------------------------------------
For this assignment you're going to implement a part of the k-means clustering algorithm. To be able to update the centroids of the clusters, we need to know which points of the dataset belong to which cluster.
You should complete the implementation of assign_points(), which takes the following parameters:
The function returns a list that contains for each data point the index to its closest centroid. Use the Manhattan distance for the distance computation. The Manhattan Distance is calculated as follows:
for two -dimensional points and .
If a data point has the same minimum Manhattan distance to multiple centroids, your function should assign the data point to the centroid with the highest index among those tied centroids.
centroids := np.array([[-1, 0], [5, 5], [2, 0]])
A Python list [0, 2]
| 1 | import numpy as np |
|---|---|
| 2 | import sys |
| 3 | |
| 4 | class Solution(): |
| 5 | |
| 6 | def assign_points(points, centroids): |
| 7 | |
| 8 | indices = [] |
| 9 | |
| 10 | for p in points: |
| 11 | mindist = sys.maxsize |
| 12 | for i, c in enumerate(centroids): |
| 13 | dist = np.sum(np.abs(p - c)) |
| 14 | if dist <= mindist: |
| 15 | mindist = dist |
Specification Test
Layout: IIII ▾
Solution
Welcome to the exam for CSE22A Machine Learning!
There are three types of questions: multiple choice questions, open questions and implementation questions.
The amount of points you can earn per question vary. Wrong answers result in 0 points.
For questions with images, you can enlarge the image by clicking on it. For your convenience we advise you to have paper, pen and a calculator ready during the exam.
If you want to consult the Python (3.8) or NumPy documentation for the implementation questions, they should be accessible here:
We wish you the best of luck!
| Type | Assignment | Weight | Due |
|---|---|---|---|
| Practice Exam 1 [Published] | 1.0 (of 11.0) | ||
| [MC] | [Start Here] Code of Honour [Published] | 0.0 (of 1.0) | |
| [Random Collection] | Questions [Published] | 1.0 (of 1.0) | |
| [Essay] | [End Here] Feedback [Published] [Manual Grading] | 0.0 (of 1.0) |
Statistics and aggregrated grades were last updated 7 months ago. Grade and Statistics updates are disabled.
Consider the following pdf’s of two classes in a 1D feature space: 
The solution for this assignment has been made available, but you need to unlock it first.
In case you have difficulties with this assignment, it may be more effective to ask a teaching assistant for help first.
By unlocking this answer, you understand that your submission grade may not be representative for your performance on this topic anymore. Consider this action as asking the course staff to provide the answer. While the course staff won't get notified, the timestamp of accessing the answer will be available to the course staff.
Do you want to proceed?
The solution for this assignment has been made available, but you need to unlock it first.
In case you have difficulties with this assignment, it may be more effective to ask a teaching assistant for help first.
By unlocking this answer, you understand that your submission grade may not be representative for your performance on this topic anymore. Consider this action as asking the course staff to provide the answer. While the course staff won't get notified, the timestamp of accessing the answer will be available to the course staff.
Do you want to proceed?
The solution for this assignment has been made available, but you need to unlock it first.
In case you have difficulties with this assignment, it may be more effective to ask a teaching assistant for help first.
By unlocking this answer, you understand that your submission grade may not be representative for your performance on this topic anymore. Consider this action as asking the course staff to provide the answer. While the course staff won't get notified, the timestamp of accessing the answer will be available to the course staff.
Do you want to proceed?
Which of these claims is true for gradient descent?
Assume we have a 5-dimensional dataset with 2 classes, and assume we want to fit a Quadratic Discriminant Analysis on this dataset. How many free parameters do we have to estimate? (Note: the number of free parameters of a 5-dimensional mean is 5.)
Select one option
Which of the following statements best characterizes a duty ethics moral approach?
Assignment Link: https://weblab.tudelft.nl/cse2510/2023-2024/assignment/119930/ Weight: 1.0 of total 42.5 Minimum to Pass: Not set Deadline: No deadline A personal deadline may be set, check your submission page
Based on the characteristics of a patient, I would like to predict the glucose level (a continuous value) in someone’s blood. To train this model, I use a lot of historical samples containing characteristics of previous patients and their blood glucose levels. What type of machine learning task is this? Select one option
This is a private discussion, only visible to course staff and submitter of this work.
In this exercise, we want to calculate the information gain of different binary splits to determine the best one. Here, we consider only one discrete feature.
We have n objects which we denote using a vector of n labels and a vector which contains the feature values.
y contains the labels (0 (negative) and 1 (positive)) corresponding to each object.
x contains the value of the feature of each object.
E.g. if we have the following labels: [0,0,0,0,1,1,1,1] and feature values: [0,1,2,0,1,2,0,1], then if we consider the binary split 1 vs. not-1 we end up with the following sets of labels: [0,1,1], [0,0,0,1,1].
Calculate the information gain (in terms of entropy) for each binary split.
The formula for entropy is:
The formula for overall (split-)entropy is:
in which s is the number of nodes after the split.
Return the information gain resulting from the each split ().
Implement the following:
entropy(y) a function that computes the entropysplit_entropy(y,x,split_value) a function that computes the split-entropy, for a particular binary splitinformation_gain(y,x,split_value) a function that calculates the information gain for a particular binary splitHint 1: to call a function from the Solution class you can use: Solution.function() Hint 2: Make sure you are also able to handle the situation in which all objects in a node belong to the same class (the entropy of such a node is 0).
Part 1 of 3 — loading the next…
| 3 |
| 4 |
| 5 |
| ☑ 6 |
| 7 |
| □ 8 |
| □ 9 |
| 8 |
| 9 |
| 10 | for c in np.unique(labels): |
| 11 |
| 12 |
| 13 | return gini |
| 14 |
| 15 | def compute_gain(labels, subsets): |
| 16 | return Solution.compute_gini_index(labels) - Solution.compute_split_gini(labels, subsets) |
| 17 |
| 18 | def compute_split_gini(labels, subsets): |
| 19 | information = 0 |
| 20 | n = len(labels) |
| 21 |
| 22 | for i in np.unique(subsets): |
| 23 | subset_labels = labels[subsets == i] |
| 24 | information += len(subset_labels) / n * Solution.compute_gini_index(subset_labels) |
| 25 | return information |
| 15 |
| 16 | def compute_gradient(w, X, Y): |
| 17 | XT_w = w.T @ X.T |
| 18 | h_x = 1 / (1 + np.exp(-XT_w)) |
| 19 | gradients = ((Y - h_x) * X.T).T |
| 20 |
| 21 |
| 22 | return -1 * gradients.mean(axis=0) |
| , , so |
| Decision boundary is therefore at |
| From class we get an error of |
| From class we get an error of |
| In total |
| 16 | label_index = i |
| 17 | indices.append(label_index) |
| 18 |
| 19 | return indices |
| 20 |