Quiz Space

September 2023 term · Machine Learning Practice · BSCS2008

MLP End Term: 24 December 2023, Set FDD1 (September 2023 term)

The IIT Madras BS Machine Learning Practice (MLP) End Term paper sat on 24 Dec 2023, in the September 2023 term, set FDD1: 38 questions for 100 marks in 180 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
38
Marks
100
Duration
180 min
MCQ
22
MSQ
11
Numerical
5

Updated

Official paper: IIT M DIPLOMA FN EXAM FDD1 24 Dec 2023 · No negative marking.

Question 1

+2 marksOne correct option

Consider the following Python code using Pandas:

What does the groupby operation in the code achieve?

  1. A

    It calculates the total price for each category.

  2. B

    It calculates the average price for each category.

  3. C

    It groups the data by the ’Category’ column.

  4. D

    It filters out rows where the ’Price’ column is zero.

Show answer

Correct answer

  • B

    It calculates the average price for each category.

Question 2

+2 marksOne correct option

Consider the below code:

python
data = [[-3, 1],
[-3, 1],
[ 3, 5],
[ 3, 5]]
from sklearn.preprocessing import StandardScaler
ss = StandardScaler()
print(ss.fit_transform(data))

Which of the following option represents the print output :

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

Correct answer

  • D

Question 3

+2 marksOne correct option

Which of the following metrics indicate higher their value, better the regression model’s performance?

  1. A

    RMSE

  2. B

    R2

  3. C

    Mean absolute error

  4. D

    Mean squared error

Show answer

Correct answer

  • B

    R2

Question 4

+2 marksOne correct option

Which of the following variations of gradient descent can be implemented with SGDClassifier?

  1. A

    stochastic gradient descent

  2. B

    mini gradient descent

  3. C

    full batch gradient descent

  4. D

    None of these

Show answer

Correct answer

  • A

    stochastic gradient descent

Question 5

+2 marksOne correct option

Consider the Ridge regression model in scikit-learn, represented by the Ridge class.
Which of the following statements about Ridge regression is correct?

  1. A

    Ridge regression is designed to handle class imbalance of the dataset.

  2. B

    The regularization term in Ridge regression is added to the sum of absolute residuals.

  3. C

    Increasing the value of the regularization parameter (alpha) in Ridge regression makes the model less sensitive to high-magnitude coefficients.

  4. D

    Ridge regression is equivalent to Lasso regression when the regularization parameter (alpha) is set to zero.

Show answer

Correct answer

  • C

    Increasing the value of the regularization parameter (alpha) in Ridge regression makes the model less sensitive to high-magnitude coefficients.

Question 6

+2 marksOne correct option

Which of the following method is used to estimate the probabilities in SGD-Classifier with suitable loss?

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

Correct answer

  • A

Question 7

+2 marksOne correct option
  1. A

    Faster to compute the list of neighbors on scaled data.

  2. B

    k-nearest neighbors is based on computing some distances. Features need to be normalized to contribute approximately equally to the distance computation.

  3. C

    Scaling the data has a negligible effect on k-nearest neighbor’s performance, but it enhances the interpretability of the model.

  4. D

    This is irrelevant. One could use k-nearest neighbors without normalizing the dataset and get a very similar cross-validation score.

Show answer

Correct answer

  • B

    k-nearest neighbors is based on computing some distances. Features need to be normalized to contribute approximately equally to the distance computation.

Question 8

+2 marksOne correct option

When using CountVectorizer in scikit-learn, what does the max_features parameter control?

  1. A

    The maximum number of documents considered during vectorization.

  2. B

    The maximum number of features (words) to be extracted based on term frequency.

  3. C

    The maximum number of randomly selected features (words).

  4. D

    The maximum number of characters allowed in each document.

Show answer

Correct answer

  • B

    The maximum number of features (words) to be extracted based on term frequency.

Question 9

+2 marksOne correct option

Which of these may NOT help in handling overfitting in decision trees?

  1. A

    Increasing the value of min_samples_split

  2. B

    Increasing the value of the pruning parameter

  3. C

    Increasing the value of min_samples_leaf

  4. D

    Increasing the depth of the tree

Show answer

Correct answer

  • D

    Increasing the depth of the tree

Question 10

+2 marksOne correct option

Which of the following is/are Clustering Method.

  1. A

    Connectivity-based Clustering

  2. B

    Centroids-based Clustering

  3. C

    Density-based Clustering

  4. D

    All of them

Show answer

Correct answer

  • D

    All of them

Question 11

+2 marksOne correct option

You’re working with a large image and want to group similarly coloured segments in the image together. No other information is provided with the image. Which of the following techniques will you use to accomplish the task?

  1. A

    Supervised learning

  2. B

    Unsupervised learning

  3. C

    Reinforcement learning

  4. D

    None of these

Show answer

Correct answer

  • B

    Unsupervised learning

Question 12

+2 marksOne correct option
  1. A

    logistic

  2. B

    relu

  3. C

    identity

  4. D

    tanh

Show answer

Correct answer

  • C

    identity

Question 13

+3 marksOne correct option
  1. A

    [5, 5, 3.75]

  2. B

    [5, 5, 3]

  3. C

    [4, 4, 3]

  4. D

    [4, 4, 3.75]

Show answer

Correct answer

  • B

    [5, 5, 3]

Question 14

+3 marksOne correct option

Consider the following code snippet using scikit-learn:

python
pipeline = Pipeline([
('scaler', StandardScaler()),
('classifier', SVC())])
param_grid = {'scaler__with_mean': [True, False],
'classifier__C': [0.1, 1, 10],
'classifier__kernel': ['linear', 'rbf'],
'classifier__gamma': [0.1, 1, 10]}
grid_search = GridSearchCV(pipeline, param_grid, cv=5, scoring='accuracy')
grid_search.fit(X_train, y_train)

Assume that X_train and y_train are training feature matrix and label vector, respectively. Which of the following statements about the given code is correct?

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

Correct answer

  • B

Question 15

+3 marksOne correct option

Which of the following code snippets represent correct methods to obtain cross validated performance measure using LeaveOneOut?

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

Correct answer

  • A

Question 16

+3 marksOne correct option
  1. A

    (71)

  2. B

    (71, 1)

  3. C

    (10)

  4. D

    (10, 2)

Show answer

Correct answer

  • C

    (10)

Question 17

+3 marksOne correct option

You’re building an ‘MLPClassifier‘ for a dataset with a large number of features. The goal is to predict whether a patient is going to have parkinson disease in next
12 months. You’re trying to decide the appropriate number of neurons in the hidden layers of the neural network. Which statement about adjusting the hidden_layer_sizes parameter is correct?

  1. A

    Increasing the number of neurons in hidden layers will always lead to better model performance.

  2. B

    Decreasing the number of neurons in hidden layers reduces the model’s capacity to capture complex patterns.

  3. C

    The number of neurons in hidden layers does not significantly affect the model’s performance.

  4. D

    Finding the optimal number of neurons is a trial-and-error process and may require experimentation.

Show answer

Correct answer

  • D

    Finding the optimal number of neurons is a trial-and-error process and may require experimentation.

Question 18

+3 marksOne correct option

Which of the following code snippet can correctly plot the elbow graph for feature matrix X (k value is taken from 1 to 10)?

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

Correct answer

  • C

Question 19

+3 marksOne correct option

You're working on a binary classification task using the ‘MLPClassifier’ to predict whether a customer will make a purchase based on their browsing behavior. You're concerned about underfitting due to the complexity of the data. You decide to increase the ‘alpha’ parameter to control underfitting. The following code snippet shows the application of ‘MLPClassifier’:

python
from sklearn.neural_network import MLPClassifier
import numpy as np
data = np.array([[10, 3], [20, 5], [5, 1], [15, 4], [8, 2]])
# Corresponding target labels (0: No Purchase, 1: Purchase)
target = np.array([0, 1, 0, 1, 0])
# Initialize MLPClassifier with alpha parameter
clf = MLPClassifier(alpha=0.001, random_state=42)
clf.fit(data, target)
# Predict class labels
predicted_labels = clf.predict(data)

By setting/changing the ‘alpha’ parameter to 0.01, how are you affecting the neural network model's behavior?

  1. A

    Increasing the model’s complexity to fit the training data more closely.

  2. B

    Adding a stronger regularization term to the loss function, discouraging complex models.

  3. C

    Making the model more capable to learn more complex behaviour.

  4. D

    Adjusting the learning rate to control convergence speed.

Show answer

Correct answer

  • C

    Making the model more capable to learn more complex behaviour.

Question 20

+4 marksOne correct option

The following code produces an output of 0.9125. How is the output expected to change if we increase the max_depth value?:

python
from sklearn.datasets import load_wine
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
X,y = load_wine(as_frame = True, return_X_y = True)
X_train,X_test,y_train,y_test = train_test_split(X,
y,
test_size = 0.10,
random_state = 12)
clf = DecisionTreeClassifier(max_depth = 2,
min_samples_split = 2,
min_samples_leaf=3,
random_state = 81)
clf.fit(X_train, y_train)
print(clf.score(X_train, y_train))
  1. A

    Output score is likely to increase.

  2. B

    Output score is likely to decrease.

  3. C

    Output score may increase or decrease.

  4. D

    Output score will remain the same.

Show answer

Correct answer

  • A

    Output score is likely to increase.

Question 21

+4 marksOne correct option

Consider the following block of code for the binary classification dataset.

Shape of feature matrix is (10000,4) and labels (10000,) respectively.

keep following symbols in mind:

  • >>>: Represents input code
  • # : Represents comment in a code
  • ... : Represents code continuation
  • Without any symbols at the beginning of a line then it is output of just above input line of code.
python
>>> from sklearn.linear_model import LogisticRegression,SGDClassifier
>>> from sklearn.naive_bayes import GaussianNB
>>> from sklearn.ensemble import VotingClassifier
>>> clf1 = LogisticRegression(multi_class='multinomial', random_state=1)
>>> clf2 = SGDClassifier(random_state=1)
>>> clf3 = GaussianNB()
>>> eclf = VotingClassifier(estimators=[('lr', clf1),
... ('sgd', clf2),
... ('gnb', clf3)],
... voting='soft')
>>> eclf.fit(X,y)
>>> eclf.named_estimators_['lr'].predict_proba(X[0:1])
[0.4,0.6]
>>> eclf.named_estimators_['sgd'].predict_proba(X[0:1])
[0.25,0.75]
>>> eclf.named_estimators_['gnb'].predict_proba(X[0:1])
[0.9,0.1]

what will be the predicted class for X[0:1] sample using the code given above

  1. A

    0

  2. B

    1

  3. C

    2

  4. D

    3

Show answer

Correct answer

  • B

    1

Question 22

+4 marksOne correct option

Given the following code using BaggingClassifier with KNeighborsClassifier as the base estimator:

python
from sklearn.ensemble import BaggingClassifier
from sklearn.neighbors import KNeighborsClassifier
base_knn = KNeighborsClassifier(n_neighbors=3, weights='distance')
bag_clf = BaggingClassifier(base_knn,
n_estimators=30,
max_samples=100,
bootstrap=False,
random_state=42)

Which of the following statements is correct?

  1. A

    Above code uses bootstrapping to generate samples for each base classifier.

  2. B

    model will be tested on out of the bags samples.

  3. C

    Due to weights=’distance’, each base KNN classifier will treat all neighbors equally in terms of voting power.

  4. D

    The ensemble will consist of 3 base KNN classifiers.

  5. E

    None of these

Show answer

Correct answer

  • E

    None of these

Question 23

+2 marksOne or more correct options

Consider a dataset representing various attributes of red wine, loaded into a Pandas DataFrame named data using the following code:

Suppose we are interested in extracting the value of the chlorides attribute for the third sample in the dataset (2nd by index). Which of the following expressions correctly achieves this? chlorides is at the 4th index of columns.

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 24

+2 marksOne or more correct options

Consider the following Python code snippet that demonstrates the use of SGDClassifier from scikit-learn:

python
clf = SGDClassifier(loss="hinge",
penalty="l2",
max_iter=500,
warm_start=True)
clf.fit(X_train,y_train)

Choose the correct statements:

Select all that apply.

  1. A

    It applies lasso penalty.

  2. B

    The training may terminate after 499 iterations or lesser

  3. C

    the classifier represents a perceptron model

  4. D

    The classifier’s model parameters will initialized with parameters learnt from previous call to fit() function, if the same object is trained/fitted multiple times on new data.

Show answer

Correct answers

  • B

    The training may terminate after 499 iterations or lesser

  • D

    The classifier’s model parameters will initialized with parameters learnt from previous call to fit() function, if the same object is trained/fitted multiple times on new data.

Question 25

+2 marksOne or more correct options

Which of the following observations warrant use of SGD model?

Select all that apply.

  1. A

    The data set size is 1000 GB.

  2. B

    The model has to be trained in non-iterative manner.

  3. C

    The model must be a decision tree.

  4. D

    The model must be a logistic regressor.

  5. E

    None of these

Show answer

Correct answers

  • A

    The data set size is 1000 GB.

  • D

    The model must be a logistic regressor.

Question 26

+2 marksOne or more correct options

Select all that apply.

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

Correct answers

  • A
  • C

Question 27

+2 marksOne or more correct options

Select all that apply.

  1. A

    ‘poly’,

  2. B

    ‘lasso’

  3. C

    ‘rbf’,

  4. D

    ‘scale’

Show answer

Correct answers

  • A

    ‘poly’,

  • C

    ‘rbf’,

Question 28

+3 marksOne or more correct options

consider the below code :

keep following symbols in mind:

  • >>>: Represents input code
  • # : Represents comment in a code
  • ... : Represents code continuation
  • Without any symbols at the beginning of a line then it is output of just above input line of code.
  • arrow pointing towards right is code continuation to another line.
python
>>> from sklearn.feature_selection import SelectKBest, chi2
>>> from sklearn.datasets import load_wine
>>> X,y = load_wine(return_X_y=True,as_frame=True)
>>> print(X.shape)
(178, 13)
>>> print(X.columns)
['alcohol', 'malic_acid', 'ash', 'alcalinity_of_ash', 'magnesium',
↪ 'total_phenols', 'flavanoids', 'nonflavanoid_phenols',
↪ 'proanthocyanins', 'color_intensity', 'hue',
↪ 'od280/od315_of_diluted_wines', 'proline']
>>> skb = SelectKBest(chi2, k=3)
>>> X_selected = skb.fit_transform(X, y)
>>> print(skb.scores_)
[5.44, 28.06, 0.74, 29.38, 45.02, 15.62, 63.33, 1.81, 9.36, 109.01, 5.18,
↪ 23.38, 16540.06]
>>> print(skb.pvalues_)
[6.56e-02, 8.03e-07, 0.68, 4.16e-07, 1.66e-10, 4.05e-04, 1.76e-14, 0.40,
↪ 9.24e-03, 2.12e-24, 0.074, 8.33e-06, 0]
>>> print(skb.pvalues_.argsort())
[12, 9, 6, 4, 3, 1, 11, 5, 8, 0, 10, 7, 2]

Which of the following feature(s) will be selected in X_selected from X ?

Select all that apply.

  1. A

    malic_acid

  2. B

    magnesium

  3. C

    flavanoids

  4. D

    proanthocyanins

  5. E

    color_intensity

  6. F

    proline

Show answer

Correct answers

  • C

    flavanoids

  • E

    color_intensity

  • F

    proline

Question 29

+3 marksOne or more correct options

Consider the following code snippet using scikit-learn:

python
sgd_regressor = SGDRegressor()
param_dist = { 'loss': ['squared_loss', 'huber', 'epsilon_insensitive'],
'alpha': loguniform(1e-4, 1e0),
'penalty': ['l1', 'l2', 'elasticnet'],
'epsilon': loguniform(1e-4, 1e-1),}
random_search = RandomizedSearchCV(sgd_regressor,
param_distributions=param_dist, n_iter=10, cv=3,
scoring='neg_mean_squared_error')
random_search.fit(X, y)

Assume all the necessary imports and X,yX, y to be the training dataset. Which of the following statements about the given code are correct?

Select all that apply.

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

Correct answers

  • A
  • C
  • D

Question 30

+3 marksOne or more correct options

Consider following code:

python
import numpy as np
from sklearn.model_selection import KFold
X = np.array([47, 31, 18, 95, 85, 77])
kf = KFold(n_splits=3)
for train, test in kf.split(X):
print(X[train])

Which of the following options can not be printed?

Select all that apply.

  1. A

    [47, 31, 18, 95, 77]

  2. B

    [47, 31, 18 ]

  3. C

    [31, 41, 18, 95, 85, 77]

  4. D

    [31, 41, 85, 31]

  5. E

    [18, 95, 85, 77]

  6. F

    [47, 31, 18, 85]

  7. G

    None of these

Show answer

Correct answers

  • A

    [47, 31, 18, 95, 77]

  • B

    [47, 31, 18 ]

  • C

    [31, 41, 18, 95, 85, 77]

  • D

    [31, 41, 85, 31]

Question 31

+3 marksOne or more correct options

When using a Support Vector Classifier (SVC) in scikit-learn with different values of the regularization parameter (C), how does the complexity of the decision boundary change? Select all correct statements:

Select all that apply.

  1. A

    Smaller values of C result in a more complex decision boundary.

  2. B

    Larger values of C result in a more complex decision boundary.

  3. C

    The decision boundary becomes simpler with increasing values of C.

  4. D

    Very large values of C may lead to overfitting.

Show answer

Correct answers

  • B

    Larger values of C result in a more complex decision boundary.

  • D

    Very large values of C may lead to overfitting.

Question 32

+4 marksOne or more correct options

Consider the following block of code:

python
from sklearn.datasets import load_breast_cancer
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split
X,y = load_breast_cancer(as_frame = True,
return_X_y = True)
X_train,X_test,y_train,y_test = train_test_split(X,y,
test_size = 0.2,
random_state = 1)
clf = DecisionTreeClassifier(min_samples_split = 5,
min_samples_leaf = 3,
random_state = 5)
clf.fit(X_train, y_train)
print(clf.score(X_test, y_test))

In which of the following scenarios, the split will NOT be made at node N?

Select all that apply.

  1. A

    Number of samples at node N = 10. If it is split, it will result in 2 nodes in the left child and 8 nodes in the right child.

  2. B

    Number of samples at node N = 6. If it is split, it will result in 3 nodes in the left child and 3 nodes in the right child.

  3. C

    Number of samples at node N = 12. If it is split, it will result in 5 nodes in the left child and 7 nodes in the right child.

  4. D

    Number of samples at node N = 4. If it is split, it will result in 3 nodes in the left child and 1 node in the right child.

Show answer

Correct answers

  • A

    Number of samples at node N = 10. If it is split, it will result in 2 nodes in the left child and 8 nodes in the right child.

  • D

    Number of samples at node N = 4. If it is split, it will result in 3 nodes in the left child and 1 node in the right child.

Question 33

+3 marksNumerical answer

Consider the following code and its output:

keep following symbols in mind:

  • >>>: Represents input code
  • # : Represents comment in a code
  • ... : Represents code continuation
  • Without any symbols at the beginning of a line then it is output of just above input line of code.
python
>>> from sklearn.datasets import load_iris
>>> from sklearn.linear_model import LogisticRegression
>>> X, y = load_iris(return_X_y=True)
>>> clf = LogisticRegression(random_state=0).fit(X, y)
>>> print(y[70:80])
[1 0 1 0 1 1 1 0 0 1]
>>> print(clf.predict(X[70:80, :]))
[0 1 1 0 1 1 1 0 1 0]
>>> print(clf.score(X[70:80, :], y[70:80]))

What will be the output of the above code? Enter your answer correct to one decimal place.

Show answer

Correct answer: 0.6

Question 34

+3 marksNumerical answer

What will be the output of the following code?

python
from sklearn.neighbors import KNeighborsClassifier
X_train = [[1,100],[4,400],[5,500],[6,600],[8,800],[9,900],
[11,1100],[12,1200],[15,1500], [18,1800],[19,1900]]
y_train = [1,1,1,1,1,1,1,1,2,2,2]
X_test = [[2,200]]
knn = KNeighborsClassifier(n_neighbors= 7,
metric="euclidean",
weights= 'uniform')
knn.fit(X_train,y_train)
print(knn.predict(X_test))
Show answer

Correct answer: 1

Question 35

+2 marksNumerical answer

Consider the following code snippet:

python
from sklearn.neighbors import KNeighborsClassifier
X_train = [[1, 2], [3, 4], [5, 6]]
y_train = [0, 1, 0]
knn = KNeighborsClassifier(n_neighbors=3)
knn.fit(X_train, y_train)

What will be the output of the following code:

python
print(len(knn.classes_))
Show answer

Correct answer: 2

Question 36

+4 marksNumerical answer

Consider the following code. How many DecisionTreeClassifier models will be trained internally?

python
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import GridSearchCV
param_grid = [{'max_depth':range(1, 20, 2)}]
gs = GridSearchCV(RandomForestClassifier(n_estimators=10), param_grid, cv =
5)
gs.fit(X,y)
Show answer

Correct answer: 500

Question 37

+3 marksNumerical answer

Please consider the following data and code for a regression problem with following symbols in mind:

  • >>>: Represents input code
  • # : Represents comment in a code
  • ... : Represents code continuation
  • Without any symbols at the beginning of a line then it is output of just above input line of code.
AgeCar_colorAccidents_per_1000_Driver
019Black74
119Blue75
219Red85
324Black70
424Blue70
524Red89
630Black78
730Blue76
830Red90

Target column: Accidents_per_1000_Driver

python
>>> import pandas as pd
>>> from sklearn.preprocessing import OneHotEncoder
>>> from sklearn.linear_model import LinearRegression
>>> data = pd.DataFrame([[19, 'Black', 74],
... [19, 'Blue', 75],
... [19, 'Red', 85],
... [24, 'Black', 70],
... [24, 'Blue', 70],
... [24, 'Red', 89],
... [30, 'Black', 78],
... [30, 'Blue', 76],
... [30, 'Red', 90]],
columns=["Age","Car_color","Accidents_per_1000_Driver"])
>>> X = data.drop("Accidents_per_1000_Driver", axis=1)
>>> y = data["Accidents_per_1000_Driver"]
>>> ohe = OneHotEncoder(sparse_output=False)
>>> X[['Black', 'Blue', 'Red']] = ohe.fit_transform(X[["Car_color"]])
>>> X.drop("Car_color", axis=1, inplace=True)
>>> lr = LinearRegression().fit(X, y)
>>> print(lr.coef_)
[0.32, -4.55, -4.88, 9.44]
>>> print(lr.intercept_)
70.75

Based on the above data, answer the given subquestions.

How many Accidents per 1000 Driver happens for Age 25 and driving blue car ?

Show answer

Correct answer: 74 (accepted within ±1)

Question 38

+2 marksOne or more correct options

Please consider the following data and code for a regression problem with following symbols in mind:

  • >>>: Represents input code
  • # : Represents comment in a code
  • ... : Represents code continuation
  • Without any symbols at the beginning of a line then it is output of just above input line of code.
AgeCar_colorAccidents_per_1000_Driver
019Black74
119Blue75
219Red85
324Black70
424Blue70
524Red89
630Black78
730Blue76
830Red90

Target column: Accidents_per_1000_Driver

python
>>> import pandas as pd
>>> from sklearn.preprocessing import OneHotEncoder
>>> from sklearn.linear_model import LinearRegression
>>> data = pd.DataFrame([[19, 'Black', 74],
... [19, 'Blue', 75],
... [19, 'Red', 85],
... [24, 'Black', 70],
... [24, 'Blue', 70],
... [24, 'Red', 89],
... [30, 'Black', 78],
... [30, 'Blue', 76],
... [30, 'Red', 90]],
columns=["Age","Car_color","Accidents_per_1000_Driver"])
>>> X = data.drop("Accidents_per_1000_Driver", axis=1)
>>> y = data["Accidents_per_1000_Driver"]
>>> ohe = OneHotEncoder(sparse_output=False)
>>> X[['Black', 'Blue', 'Red']] = ohe.fit_transform(X[["Car_color"]])
>>> X.drop("Car_color", axis=1, inplace=True)
>>> lr = LinearRegression().fit(X, y)
>>> print(lr.coef_)
[0.32, -4.55, -4.88, 9.44]
>>> print(lr.intercept_)
70.75

Based on the above data, answer the given subquestions.

To improve the given model which of the following preprocessing step you suggest?

Select all that apply.

  1. A

    StandardScaler()

  2. B

    OrdinalEncoder()

  3. C

    MinMaxScaler()

  4. D

    LabelEncoder()

Show answer

Correct answers

  • A

    StandardScaler()

  • C

    MinMaxScaler()