uiz Space

January 2023 term · Machine Learning Practice · BSCS2008

Machine Learning Practice Quiz 1: 26 February 2023 (January 2023 term)

The IIT Madras BS Machine Learning Practice (MLP) Quiz 1 paper sat on 26 Feb 2023, in the January 2023 term: 23 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
23
Marks
50
Duration
120 min
Written
1
MCQ
18
MSQ
4

Updated

Official paper: IIT M DIPLOMA AN2 EXAM QPD2 26 Feb 2023 · No negative marking.

Question 1

+2 marksWritten answer

[String Matching] Enter the sequence of steps to be followed, in general, in end to end machine learning project. Enter the answer as a 6-character string. For example, entering the answer as (without quotes) ‘BADCFE’ implies that the first step is B, followed by the second step A and so on. A. Select suitable model
B. Train the model
C. Pre-process the data
D. Collect data
E. Fine tune model
F. Present your solution

Show answer

Correct answer: DCABEF

Question 2

+1 markOne correct option

Which of the following APIs can be used to construct an ML pipeline for data preprocessing and modeling?

  1. A

    Pipeline

  2. B

    ColumnTransformer

  3. C

    FeatureUnion

  4. D

    All of these

Show answer

Correct answer

  • D

    All of these

Question 3

+1 markOne correct option

Consider following data:

Which one of the following APIs can be used to extract features from the above data?

  1. A

    DictVectorizer

  2. B

    HashingVectorizer

  3. C

    FeatureHasher

Show answer

Correct answer

  • A

    DictVectorizer

Question 4

+1 markOne correct option

Consider following data:

X=[83np.nan83np.nan10677]\mathbf{X} = \begin{bmatrix} 8 & 3 \\ np.nan & 8 \\ 3 & np.nan \\ 10 & 6 \\ 7 & 7 \end{bmatrix}

What will be the output of the following code? (Assume necessary imports)

python
si = SimpleImputer(strategy='mean')
Xnew = si.fit_transform(X)
print(f'{Xnew[1,0]}, {Xnew[2,1]}')
  1. A

    7,6

  2. B

    6,6

  3. C

    6,7

  4. D

    7,7

Show answer

Correct answer

  • A

    7,6

Question 5

+2 marksOne correct option

Suppose that we load a data set that contains 1000 samples in a Pandas Dataframe. Each sample has 30 features. However, a few samples in the data set miss the values for all features. Therefore, those samples need to be dropped. Choose the method that removes such samples from the dataset?

  1. A

    drop(columns=[‘all’])

  2. B

    drop(how=‘all’)

  3. C

    dropna()

  4. D

    dropna(how=‘all’)

  5. E

    dropna.all()

Show answer

Correct answer

  • D

    dropna(how=‘all’)

Question 6

+2 marksOne correct option

The statement that each feature in the input data set has a (physical) meaning associated with it is

  1. A

    True, for all ML problems

  2. B

    True, for some ML problems

  3. C

    False, for all ML problems

  4. D

    can not be decided

Show answer

Correct answer

  • B

    True, for some ML problems

Question 7

+2 marksOne correct option

A company collects 40000 samples (examples) to build a Machine Learning model for an application. They decide to use 30% of the total samples for testing (to be stored in the variable trainset) and the rest 70% for training (to be stored in the variable trainset). They also want to sample the same set of samples across multiple runs. Which of the following line (statement) achieves this task? Assume that all samples are stored in the variable data.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 8

+2 marksOne correct option

Which of the following utilities of sklearn.datasets helps us to get the realworld data from the internet?

  1. A

    load_

  2. B

    fetch_

  3. C

    generate_

  4. D

    get_

Show answer

Correct answer

  • B

    fetch_

Question 9

+2 marksOne correct option

Consider the following ML task/steps for a regression dataset:
1. Read the data from a file (named ‘dataset.csv’). It has 7 columns. The last column is the target variable, the rest of them are numerical features.
2. Drop rows with missing values.
3. After removing samples with missing values split the data into training and test sets. Take about the first 80% of rows in the training set and the rest of them into the test set.
4. Train a simple linear regression model, with intercept, on the training set.
5. Report R2 score on the test set.
Which of the following code snippets correctly accomplishes the above task? Assume necessary imports.

  1. A
  2. B
  3. C
  4. D
  5. E
Show answer

Correct answer

  • A

Question 10

+2 marksOne correct option

Consider the following code where X_train, y_train is the training data. X_test, y_test is the test data.

Which evaluation metric will be contained in the ‘score’?

  1. A

    mean_squared_error

  2. B

    mean_absolute_error

  3. C

    R2_score

  4. D

    Accuracy

Show answer

Correct answer

  • C

    R2_score

Question 11

+2 marksOne correct option

How to make SGDRegressor stop after 1000 epochs?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 12

+2 marksOne correct option

Suppose we want to transform features in a dataset using polynomial transformation. The sklearn API provides the functionality in which of the following modules?

  1. A

    sklearn.dataset

  2. B

    sklearn.model_selection

  3. C

    sklearn.preprocessing

  4. D

    sklearn.featureSelection

  5. E

    sklearn.featureExtraction

Show answer

Correct answer

  • C

    sklearn.preprocessing

Question 13

+3 marksOne correct option

Consider following dataset:

Which one of the following code snippets will correctly preprocess above data? Assume necessary imports. The data is stored in a dataframe named X.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 14

+3 marksOne correct option

For a dataset with 1000 data points and 100 features, the following code will generate how many models during execution?
Note: X is the feature matrix and y is the target vector.

  1. A

    1000

  2. B

    100

  3. C

    99

  4. D

    999

Show answer

Correct answer

  • A

    1000

Question 15

+3 marksOne correct option

Consider the following cross-validation strategy:

Assume we apply this strategy to some data set. Which of the following options is/are correct?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 16

+3 marksOne correct option

Which of the following code is correct if we want the mean absolute error to be minimized during the computation of cross_val_score?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 17

+3 marksOne correct option

We know that applying polynomial transformation to the samples is often helpful. Assume we imported all the required modules.

  1. A

    (2,2)

  2. B

    (2,6)

  3. C

    (6,2)

  4. D

    (2,3)

  5. E

    (3,2)

  6. F

    (2,5)

  7. G

    (5,2)

Show answer

Correct answer

  • D

    (2,3)

Question 18

+3 marksOne correct option

A team has built a dataset for a regression problem. It contains 1000 samples. Each sample x is of size 2. All the features are binary, that is, xi ∈ {0, 1}. The team decided to use polynomial feature transformation of degree 2 as follows,

  1. A

    1

  2. B

    2

  3. C

    3

  4. D

    4

  5. E

    0

Show answer

Correct answer

  • B

    2

Question 19

+3 marksOne correct option

Consider a regression problem with L2 regularization. Suppose we instantiate the model as shown below,

What is the range of ‘alpha’?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 20

+2 marksOne or more correct options

(Multiple Select) Consider a data set shown below. The data set was loaded using Pandas and stored in the variable ‘data’ as a data frame.

fixed acidityvolatile aciditycitric acidresidual sugarchloridesfree sulfur dioxidetotal sulfur dioxidedensitypHsulphatesalcoholquality
07.40.700.001.90.07611.034.00.99783.510.569.45
17.80.880.002.60.09825.067.00.99683.200.689.85
27.80.760.042.30.09215.054.00.99703.260.659.85
311.20.280.561.90.07517.060.00.99803.160.589.86
47.40.700.001.90.07611.034.00.99783.510.569.45
python
data_url = '''https://archive.ics.uci.edu/ml/machine-learning-databases/
wine-quality/winequality-red.csv'''
data = pd.read_csv(data_url, sep=";")

Suppose that we want to get the value of ‘chlorides‘ of the third sample (2nd by index). Which of the following lines of code does this?

Select all that apply.

  1. A

    data.chlorides[2]

  2. B

    data[‘chlorides’][2]

  3. C

    data[2][4]

  4. D

    data.iloc[2,4]

Show answer

Correct answers

  • A

    data.chlorides[2]

  • B

    data[‘chlorides’][2]

  • D

    data.iloc[2,4]

Question 21

+2 marksOne or more correct options

(MSQ) Suppose that we plot the histogram of numerical features in a data set. This reveals which of the following information?

Select all that apply.

  1. A

    Scale of the features

  2. B

    (left or right) Skew of the distribution

  3. C

    Modes in the distribution

  4. D

    Deduce total number of samples in the dataset

Show answer

Correct answers

  • A

    Scale of the features

  • B

    (left or right) Skew of the distribution

  • C

    Modes in the distribution

  • D

    Deduce total number of samples in the dataset

Question 22

+2 marksOne or more correct options

Why is data preprocessing necessary?

Select all that apply.

  1. A

    While recording or noting down, the data collector forgot the values to be recorded and entered blanks.

  2. B

    Some columns have values only between 0 and 1.

  3. C

    The data is divided into multiple files and has to be combined.

  4. D

    The data has only numbers in all the columns.

Show answer

Correct answers

  • A

    While recording or noting down, the data collector forgot the values to be recorded and entered blanks.

  • C

    The data is divided into multiple files and has to be combined.

Question 23

+2 marksOne or more correct options

[MSQ] Which of the following will produce constantly reducing learning rates?

Select all that apply.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answers

  • B
  • D