# Exam 3


📗 Name or ID: ____________________

📗 Question 1



📗 Question 2





📗 Question 3



📗 Question 4





📗 Question 5



📗 Question 6





📗 Question 7



📗 Question 8





📗 Question 9



📗 Question 10





📗 Question 11



📗 Question 12





📗 Question 13



📗 Question 14





📗 Question 15



📗 Question 16





📗 Question 17



📗 Question 18





📗 Question 19



📗 Question 20




📗 End of Exam
:
 ***** ***** ***** ***** ***** 

 ***** ***** ***** ***** *****

📗 [1 points] Given the following confusion matrix, what is the precision for class Dragon?
Class \ Predict Cat Dog Dragon
Cat 40 10 0
Dog 10 20 10
Dragon 0 0 30

3/4
1
1/4
1/2
📗 [1 points] What is matrix.argmax(axis = 1), where matrix = numpy.array([[1, 2, 3], [4, 5, 6]])?
[2, 2]
[3, 3]
[1, 1, 1]
[2, 2, 2]
📗 [1 points] There are 4 documents, and 3 of these documents contain the token "Groot". In document 1, there are 10 tokens in total, and 5 of them are "Groot". What is the bag of words feature (without normalization) of document 1 feature "Groot"?
5
4
3
10
📗 [1 points] What is a valid simplification of numpy.linalg.solve(X, X @ y), assuming the code runs without error (and numerical instability)?
y
X
X @ y
y @ X
📗 [1 points] The shape of A is (3, 2), the shape of B is (3, 3), and the shape of C is (4, 3). What is the shape of A @ B @ C?

(Error)
(3, 3)
(4, 2)
(2, 4)
📗 [1 points] If x0 has two columns, and x = sklearn.preprocessing.PolynomialFeatures(2).fit_transform(x0) is used as the design matrix, how many weights (include coefficients and biases or intercepts) will a linear regression estimate?
6
5
4
2
📗 [1 points] df has 10 columns and 5 rows. After applying p = PCA(3) and p.fit(df), what is the shape of p.components_? Note: the rows of p.components_ are the principal components.
(3, 10)
(10, 3)
(3, 5)
(5, 3)
📗 [1 points] Given points [[1], [2], [3], [4]] and starting centroids [0] and [7], what are the centroids after the first iteration of assigning points and updating centroids, using the iterative K-Means Clustering algorithm with Manhattan distance?
[2, 4]
[1.5, 3.5]
[0, 7]
[1, 3]
📗 [1 points] The gradient vector dw at [w1, w2, w3, w4] = [-1, 1, 2, -2] is [2, -2, -1, 1], if gradient descent w = w - alpha * dw is used, which variable will increase by the largest amount in the next iteration?
w2
w1
w3
w4
📗 [1 points] Suppose dxy = skimage.filters.sobel(img) produces the dxy matrix in the following table. To highlight the edge pixels in the original image in green, image[dxy > t] = [0, 255, 0] is used, and 2 pixels are highlighted. Which value of t is used?
0 0 0 0
0 1 1 0
0 0.5 0.75 0
0 0 0 0

0.8
0.7
0.25
1
📗 [1 points] One-vs-one support vector machines are trained and produce the following the confusion matrix. How many training items are used in training the "0 vs 2" support vector machine?
Count Predict 0 Predict 1 Predict 2
Class 0 10 20 10
Class 1 0 10 0
Class 2 10 0 10

60
40
10
70
📗 [1 points] The 3-fold cross validation accuracy for four different neural networks is summarized below. Which model is the most preferred one based on cross validation accuracy?
Network Fold 1 accuracy Fold 2 accuracy Fold 3 accuracy
W 0.5 0.5 0.5
X 0.6 0.8 1
Y 0.7 0.8 0.9
Z 0.8 0.8 0.8

Z
Y
X
W
📗 [1 points] What is the optimal solution [x1, x2] to the linear program max x1 + 2 * x2 subject to x1 + x2 <= 1 and x1 >= 0 x2 >= 0?
[0, 1]
[1, 0]
[0, 0]
[1, 1]
📗 [1 points] Suppose the standard form of a linear program max c @ x subject to A @ x <= b and x >= 0 has len(c) = 5, A.shape = (3, 5), and len(b) = 3. What is the number of dual variables len(y)? Note: the dual problem is min b @ y subject to A' @ y >= c and y >= 0 where ' means transpose.
3
5
15
1
📗 [1 points] Suppose all the random vectors generated from a multivariate normal distribution are on the same line, using numpy.random.multivariate_normal([0, 0], [[1, c], [c, 4]], 1000). What is the value of c
-2
0
-1
-4
📗 [1 points] Consider a Markov chain with the following transition matrix with three states [0, 1, 2]. What is the probability a sequence [0, 0, 2] is observed (given it starts with 0)?
From \ To 0 1 2
0 1 0 0
1 0 0.5 0.5
2 0.5 0 0.5

0
0.5
0.25
1
📗 [1 points] For a logistic regression lr, if lr.predict_proba(x) for some item x is [0.3, 0.5, 0.2], what is lr.predict(x) for the same x?
1
0
2
3
📗 [1 points] What is the complete linkage Manhattan distance between c1 = [[5], [4], [0]] and c2 = [[2], [1]]? Note: c1 is a cluster with 3 points and c2 is a cluster with 2 points.
4
3
2
1
📗 [1 points] Given the principal components u1 = [0, 0, 1], u2 = [1, 0, 0], u3 = [0, 1, 0], and the PCA (principal component analysis) features of an item x is y = [-1, 0, 1], what is x
[0, 1, -1]
[-1, 0, 1]
[1, 1, 1]
[1, 0, -1]
📗 [1 points] If you think any of the questions are not clear or incorrect, please explain here; otherwise, enter "none". Please do not leave the answer blank:






Last Updated: April 29, 2024 at 1:11 AM