You are on page 1of 12

Selected Answer: True

Correct Answer: True

Question 3

Machine Learning is great for:

D. complex problems for which we have no algorithmic solution.


Selected Answer:

B. All answers are correct.


Correct Answer:

Question 4

Consider the following dataset:

ID Height Age Target-case


1 5 45 sick
2 5.11 26 sick
3 5.6 30 Not sick
4 5.9 34 Not sick
5 4.8 40 sick
6 5.8 36 Not sick
7 5.3 19 Not sick
8 5.8 28 sick

Which of the following code lines can be used for the above dataset

Selected Answers:
from sklearn.neighbors import KNeighborsClassifier
C.

from sklearn.neighbors import KNeighborsRegressor


D.
Correct Answers:
from sklearn.linear_model import LogisticRegression
A.

from sklearn.neighbors import KNeighborsClassifier


C.

Question 5

Please put the following scikit-learn codes for the iris dataset in the correct order.

Correct Answer Selected Answer

from sklearn.datasets import load_iris from sklearn.datasets import load_iris


iris = load_iris() iris = load_iris()
1. 1.

X = iris["data"] X = iris["data"]
y = iris.target y = iris.target
2. 2.

3. 3.

from sklearn.model_selection import train_test_split from sklearn.model_selection import train_te


X_train,X_test, y_train,y_test = train_test_split(X,y, test_size=0.2, random_state=4) X_train,X_test, y_train,y_test = train_test_

from sklearn.neighbors import KNeighborsClassifier from sklearn.neighbors import KNeighbor


knn = KNeighborsClassifier(n_neighbors=5) knn = KNeighborsClassifier(n_neighbors=
4. 4.

knn.fit(X_train, y_train) knn.fit(X_train, y_train)


5. 5.
y_pred=knn.predict(X_test) y_pred=knn.predict(X_test)
6. 6.

from sklearn import metrics from sklearn import metrics


score = metrics.accuracy_score(y_test,y_pred) score = metrics.accuracy_score(y_test,y_
7. 7.

Question 6

Gradient Descent cannot get stuck in a local minimum when training a Logistic Regression model because the cost
function is convex

Selected Answer: False


Correct Answer: True

Question 7

Suppose you are using Polynomial Regression. You plot the learning curves and you notice that there is a large gap
between the training error and the validation error.
The issue is that the model is overfitting the training set. This can be solved by:

Selected D.
Answer: Regularizing the model. For example, by adding an l2 penalty (Ridge) or an l1 penalty (Lasso) to the cost
function.

B. All answers are correct


Correct
Answer:

Question 8

For the good ML practice, it is recommended to split the dataset into three sets:

______________ set, Validation set & Testing set

Selected Answer: Training set


Correct Answer:
Evaluation Method Correct Answer Case Sensitivity

Contains Training

Contains training

Contains Train

Contains train

Question 9

model = SGDRegressor(max_iter=1000, tol=1e-3, penalty="l1", eta0=0.1)

l1 = Lasso

The training approach that is applied for the above code in scikit-learn tool is:

B. Stochastic Gradient Descent with indication penalty for regularization.


Selected Answer:

B. Stochastic Gradient Descent with indication penalty for regularization.


Correct Answer:

Question 10
Logistic =[A] is a =[B] supervised learning algorithm that is used to estimate the =[C] that an instance belongs to a
particular =[D].

Specified Answer for: A regression

Specified Answer for: B classification

Specified Answer for: C probability

Specified Answer for: D class

Correct Answers for: A

Evaluation Method Correct Answer Case Sensitivity

Exact Match regression

Exact Match Regression

Correct Answers for: B

Evaluation Method Correct Answer Case Sensitivity

Exact Match classification

Exact Match Classification

Correct Answers for: C

Evaluation Method Correct Answer Case Sensitivity

Exact Match probability

Exact Match Probability

Correct Answers for: D

Evaluation Method Correct Answer Case Sensitivity

Exact Match class

Exact Match Class

Exact Match type

Exact Match Type

Exact Match group

Exact Match Group

Question 11

"It is the science (and art) of programming computers so they can learn from data."

B. Machine Learning
Selected Answer:

B. Machine Learning
Correct Answer:

Question 12

How many parameters are in a linear regression model for the dataset with 5 features?

C. 7
Selected Answer:

B. 6
Correct Answer:

Question 13

The reason for the above performance of the linear regression model is:

A. The convex shape of MSE cost function


Selected Answer:

C. The very small value of the learning rate


Correct Answer:
Question 14

Suppose you want to classify pictures as outdoor/indoor and daytime/nighttime.

Which of the following classifiers you should implement?

D. Two Logistic Regression classifiers.


Selected Answer:

D. Two Logistic Regression classifiers.


Correct Answer:

Question 15

Consider the following dataset:

Examples x1 x2 class
1 6 1 0
2 7 3 0
3 8 2 0
4 9 0 0
5 8 4 1
6 8 6 1
7 9 2 1
8 9 5 1

To classify a new example (8, 3.5) using kNN classifier with manhattan distance, then the correct
answers to the following blanks are:

The closest example from the dataset is x1 = [A] & x2 = [B]

The distance to the closest example is = [C]

The class of the new example is = [D]

Specified Answer for: A 4

Specified Answer for: B 4

Specified Answer for: C 4

Specified Answer for: D 1

Correct Answers for: A

Evaluation Method Correct Answer Case Sensitivity

Exact Match 8

Correct Answers for: B

Evaluation Method Correct Answer Case Sensitivity

Exact Match 4

Correct Answers for: C

Evaluation Method Correct Answer Case Sensitivity

Exact Match 0.5

Exact Match .5

Exact Match 1/2

Correct Answers for: D

Evaluation Method Correct Answer Case Sensitivity

Exact Match 1

Question 16

In order to regularize a linear regression model, we should add:

Selected Answer:

B. to the cost function.


Correct Answer:

B. to the cost function.


Question 17

To predict the prices of cars, the type of Machine Learning algorithm that would you use is:

C. Supervised Regression Learning


Selected Answer:

C. Supervised Regression Learning


Correct Answer:

Question 18

Fill in the blank by selecting the correct answer:

___________ is a generalization approach using a similarity measure to compare new examples to


learned examples.

D. Instance-based Learning
Selected Answer:

D. Instance-based Learning
Correct Answer:

Question 19

Let's assume the following partial code:

from sklearn.linear_model import LogisticRegression

model = LogisticRegression()

model.fit(input_train, target_train)

If you have been asked to find the output of the sigmoid function, then the correct line code using
scikit-learn is: sigmoid function ‫داﻣﮫ ﻗﺎل‬
Selected Answer:
‫ﻣﻌﻨﺎﺗﮫ ﻳ�� اﺣﺘﻤﺎﻟﻴﺔ‬
output_value = model.predict_proba(input_test)
B.

Correct Answer:
output_value = model.predict_proba(input_test)
B.

Question 20

Select the appropriate answers that describe the kNN model.

A. It is an instance-based learning approach.


Selected Answers:

D. Non-parametric learning algorithm

A. It is an instance-based learning approach.


Correct Answers:

D. Non-parametric learning algorithm

Question 21

Consider a simple dataset:

Example Feature 1 Feature 2 Target


1 1 -2 Red
2 15 -5 Green
3 20 1 Green
4 5 3 Green
5 3 30 Red
6 23 19 Red
7 50 22 Green

If the values of Feature 1 are replaced by:


-0.9245221
-0.100857
0.19330917
-0.6891892
-0.8068556
0.36980884
1.95830589

This process should be called:

(Hint)

mean of feature_1= 16.714

mean of feature_2= 9.714

standard deviation of feature_1= 16.997


1 ‫�� ﻗﻴﻤﺔ أﻛ�� ﻣﻦ‬
standard deviation of feature_2= 13.683

B. Normalization
Selected Answer:

D. Standardization
Correct Answer:

Saturday, June 11, 2022 10:49:07 PM AST

← OK
6/11/22, 10:47 PM Review Test Submission: Midterm (April 19 2022) – ‫ مقدمة‬...

D. Confusion Matrix

Question 2

"It is the study of how to make computers do things at which, at the moment, people are better."

D. Artificial Intelligence
Selected Answer:

D. Artificial Intelligence
Correct Answer:

Question 3

Consider a simple dataset:

Example Feature 1 Feature 2 Target


1 1 -2 Red
2 15 -5 Green
3 20 1 Green
4 5 3 Green
5 3 30 Red
6 23 19 Red
7 50 22 Green

If the values of Feature 1 are replaced by:


-0.9245221
-0.100857
0.19330917
-0.6891892
-0.8068556
0.36980884
1.95830589

This process should be called:

(Hint)

mean of feature_1= 16.714

mean of feature_2= 9.714

standard deviation of feature_1= 16.997

standard deviation of feature_2= 13.683

D. Normalization
Selected Answer:

A. Standardization
Correct Answer:

Question 4

model = SGDRegressor(max_iter=1000, tol=1e-3, penalty="l1", eta0=0.1)

https://lms.uqu.edu.sa/webapps/assessment/review/review.jsp?attempt_id=_7983773_1&course_id=_220895_1&content_id=_1938118_1&outcome_i… 2/7
6/11/22, 10:47 PM Review Test Submission: Midterm (April 19 2022) – ‫ مقدمة‬...

The training approach that is applied for the above code in scikit-learn tool is:

C. Stochastic Gradient Descent with indication penalty for regularization.


Selected Answer:

C. Stochastic Gradient Descent with indication penalty for regularization.


Correct Answer:

Question 5

Model parameters should be the optimal values in order to use the model for predicting new
instances.

Selected Answer: True


Correct Answer: True

Question 6

Please put the following scikit-learn codes for the iris dataset in the correct order.

Correct Answer Selected Answer

from sklearn.datasets import load_iris from sklearn.datasets import load_iris


iris = load_iris() iris = load_iris()
1. 1.

X = iris["data"] X = iris["data"]
y = iris.target y = iris.target
2. 2.

3. 3.

from sklearn.model_selection import train_test_split from sklearn.model_selection import train_te


X_train,X_test, y_train,y_test = train_test_split(X,y, test_size=0.2, random_state=4) X_train,X_test, y_train,y_test = train_test_

from sklearn.neighbors import KNeighborsClassifier from sklearn.neighbors import KNeighbors


knn = KNeighborsClassifier(n_neighbors=5) knn = KNeighborsClassifier(n_neighbors=5
4. 4.

knn.fit(X_train, y_train) knn.fit(X_train, y_train)


5. 5.

y_pred=knn.predict(X_test) y_pred=knn.predict(X_test)
6. 6.

from sklearn import metrics from sklearn import metrics


score = metrics.accuracy_score(y_test,y_pred) score = metrics.accuracy_score(y_test,y_
7. 7.

Question 7

Gradient Descent cannot get stuck in a local minimum when training a Logistic Regression model because the cost
function is convex

Selected Answer: True


Correct Answer: True

Question 8

https://lms.uqu.edu.sa/webapps/assessment/review/review.jsp?attempt_id=_7983773_1&course_id=_220895_1&content_id=_1938118_1&outcome_i… 3/7
6/11/22, 10:47 PM Review Test Submission: Midterm (April 19 2022) – ‫ مقدمة‬...

For the good ML practice, it is recommended to split the dataset into three sets:

______________ set, Validation set & Testing set

Selected Answer: Training set


Correct Answer:
Evaluation Method Correct Answer Case Sensitivity

Contains Training

Contains training

Contains Train

Contains train

Question 9

Select the appropriate answers that describe the kNN model.

C. Only for classification tasks


Selected Answers:

D. It is an instance-based learning approach.

B. Non-parametric learning algorithm


Correct Answers:

D. It is an instance-based learning approach.

Question 10

Consider the following dataset:

ID Height Age Target-Weight


1 5 45 77
2 5.11 26 47
3 5.6 30 55
4 5.9 34 59
5 4.8 40 72
6 5.8 36 60
7 5.3 19 40
8 5.8 28 45

Which of the following code lines can be used for the above dataset

Selected Answers:
from sklearn.linear_model import LogisticRegression
B.
Correct Answers:
from sklearn.neighbors import KNeighborsRegressor
A.

from sklearn.linear_model import LinearRegression


C.

Question 11

Let's assume the following partial code:

from sklearn.linear_model import LogisticRegression

model = LogisticRegression()

model.fit(input_train, target_train)

https://lms.uqu.edu.sa/webapps/assessment/review/review.jsp?attempt_id=_7983773_1&course_id=_220895_1&content_id=_1938118_1&outcome_i… 4/7
6/11/22, 10:47 PM Review Test Submission: Midterm (April 19 2022) – ‫ مقدمة‬...

If you have been asked to find the class type, then the correct line code using scikit-learn is:

Selected Answer:
output_value = model.predict_proba(input_test)
B.

Correct Answer:
output_value = model.predict(input_test)
C.

Question 12

Machine Learning is great for:

C. All answers are correct.


Selected Answer:

C. All answers are correct.


Correct Answer:

Question 13

Fill in the blank by selecting the correct answer

___________ is a learning approach that is used for training a model using all the available data.

A. Model-based Learning
Selected Answer:
‫ ﻛﻤﻴﺔ اﻟﺪاﺗﺎ اﳌﺴﺘﺨﺪﻣﺔ‬، ‫اﻟﻈﺎهﺮ ان اﳌﻘﺼﻮد‬
‫ اﻧﮫ ﻛﻴﻒ �ﺴﺘﺨﺪﻣهﺎ‬... ‫وﻟ�ﺲ‬
B. Batch Learning
Correct Answer:

Question 14

To detect spam filters, the type of Machine Learning algorithm that would you use is:

D. Supervised Classification Learning


Selected Answer:

D. Supervised Classification Learning


Correct Answer:

Question 15

Suppose you want to classify pictures as outdoor/indoor and daytime/nighttime.

Which of the following classifiers you should implement?

A. Two Logistic Regression classifiers.


Selected Answer:

A. Two Logistic Regression classifiers.


Correct Answer:

Question 16

The reason for the above performance of the linear regression model is:

A. The very large value of the learning rate


Selected Answer:

https://lms.uqu.edu.sa/webapps/assessment/review/review.jsp?attempt_id=_7983773_1&course_id=_220895_1&content_id=_1938118_1&outcome_i… 5/7
6/11/22, 10:47 PM Review Test Submission: Midterm (April 19 2022) – ‫ مقدمة‬...

D. The very small value of the learning rate


Correct Answer:

Question 17

In order to regularize a linear regression model, we should add:

C. Non Of the answers


Selected Answer:

Correct Answer:

A. to the cost function.

Question 18

Logistic =[A] is a =[B] supervised learning algorithm that is used to estimate the =[C] that an instance belongs to a
particular =[D].

Specified Answer for: A regression

Specified Answer for: B classification

Specified Answer for: C propability

Specified Answer for: D class

Correct Answers for: A

Evaluation Method Correct Answer Case Sensitivity

Exact Match regression

Exact Match Regression

Correct Answers for: B

Evaluation Method Correct Answer Case Sensitivity

Exact Match classification

Exact Match Classification

Correct Answers for: C

Evaluation Method Correct Answer Case Sensitivity

Exact Match probability

Exact Match Probability

Correct Answers for: D

Evaluation Method Correct Answer Case Sensitivity

Exact Match class

Exact Match Class

Exact Match type

Exact Match Type

Exact Match group

Exact Match Group

Question 19

How many parameters are in a linear regression model for the dataset with 6 features?

D. 6
Selected Answer:

A. 7
Correct Answer:

Question 20

Suppose you are using Polynomial Regression. You plot the learning curves and you notice that there is a large gap
between the training error and the validation error.

https://lms.uqu.edu.sa/webapps/assessment/review/review.jsp?attempt_id=_7983773_1&course_id=_220895_1&content_id=_1938118_1&outcome_i… 6/7
6/11/22, 10:47 PM Review Test Submission: Midterm (April 19 2022) – ‫ مقدمة‬...
The issue is that the model is overfitting the training set. This can be solved by:

Selected Answer:
C. Increasing the size of the training set.

A. All answers are correct


Correct Answer:

Question 21

Consider the following dataset:

Examples x1 x2 class
1 6 1 0
2 7 3 0
3 8 2 0
4 9 0 0
5 8 4 1
6 8 6 1
7 9 2 1
8 9 5 1

To classify a new example (8, 3.5) using kNN classifier with manhattan distance, then the correct
answers to the following blanks are:

The closest example from the dataset is x1 = [A] & x2 = [B]

The distance to the closest example is = [C]

The class of the new example is = [D]

Specified Answer for: A 1

Specified Answer for: B 6

Specified Answer for: C 4

Specified Answer for: D 1

Correct Answers for: A

Evaluation Method Correct Answer Case Sensitivity

Exact Match 8

Correct Answers for: B

Evaluation Method Correct Answer Case Sensitivity

Exact Match 4

Correct Answers for: C

Evaluation Method Correct Answer Case Sensitivity

Exact Match 0.5

Exact Match .5

Exact Match 1/2

Correct Answers for: D

Evaluation Method Correct Answer Case Sensitivity

Exact Match 1
Saturday, June 11, 2022 10:46:45 PM AST

← OK

https://lms.uqu.edu.sa/webapps/assessment/review/review.jsp?attempt_id=_7983773_1&course_id=_220895_1&content_id=_1938118_1&outcome_i… 7/7

You might also like