Question 1
To load datasets from openml.org, which method will be appropriate?
The IIT Madras BS Machine Learning Practice (MLP) End Term paper sat on 30 Apr 2023, in the January 2023 term, set QPD1-S1: 36 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.
To load datasets from openml.org, which method will be appropriate?
Correct answer
Why is data preprocessing necessary?
Some columns have values only between 0 and 1.
A column has same entities with different names, e.g. ”India”, ”In”, ”IN”.
The data has only numbers in all the columns.
Correct answer
A column has same entities with different names, e.g. ”India”, ”In”, ”IN”.
Consider the following code block:
Correct answer
Which of the following sklearn classes will be the most suitable for examining the effect of the number of samples on the training and testing errors?
Correct answer
Which of the following is not a hyper parameter?
degree in Polynomial Regression
k in KNN
intercept value in linear regression
depth of tree in a decision tree
Correct answer
intercept value in linear regression
Consider following two statements:
Statement 1: The multinomial Naive Bayes classifier is suitable for classification with discrete features
Statement 2: Two dependent features impact GaussianNB performance because internally it calculates the conditional probability.
Both statements are True
Only statement 1 is True
Only statement 2 is True
Both statements are False
Correct answer
Both statements are True
Given below code to load a huge file name as filename.csv and this file is not loading at once in the system which parameter should be added to pd.read_csv to load this file ?
import pandas as pdfrom sklearn.linear_model import SGDRegressorfor train_df in pd.read_csv("filename.csv", __________=1024): X = train_df.iloc[:, :-1] y = train_df.iloc[:, -1] model = SGDRegressor() model.partial_fit( X,y)Correct answer
Which of the following is true for a hard margin SVM algorithm ?
It does not create hyperplanes as decision boundary
It can only work for linearly separable data
It is robust to outliers
It is mostly used for clustering the data
Correct answer
It can only work for linearly separable data
What will the output for below code
Correct answer
Which of the following APIs can be used to construct an ML pipeline that has numerical and categorical features both? Choose the most suitable answer.
Pipeline alone
ColumnTransformer with pipeline
FeatureUnion with ColumnTransformer and/or pipeline
All of these
Correct answer
FeatureUnion with ColumnTransformer and/or pipeline
Consider the following preprocessing steps:
1. Read the data from a file (named ‘dataset.csv’). It has 4 columns, with following column names ‘city’, ‘title’, ‘expert_rating’ and ‘user_rating’ in this order.
2. Drop rows with missing values.
3. Apply ‘CountVectorizer’ on ‘title’.
4. Apply one hot encoding to ‘city’.
5. Drop the remaining columns.
6. Fit and transform the data and print it.
Which of the following code snippets correctly accomplishes the above task? Assume necessary imports.
—
Correct answer
—
Consider the following code block:
from sklearn.datasets import make_regressionX, y = make_regression(n_samples = 1000, n_features = 5, n_informative = 2, random_state=42)
from sklearn.linear_model import SGDRegressorsgd1 = SGDRegressor(alpha=1e-3, random_state=42, penalty='_________________', )sgd1.fit(X, y)print(sgd1.coef_)
sgd2 = SGDRegressor(alpha=1e-3, random_state=42, penalty='__________________')sgd2.fit(X, y)print(sgd2.coef_)What are the most suitable values to be filled in the two blank spaces (in that order) in the code to expect the following output?:
[ 1.68059576e+01, 1.89752021e+01, 7.49212536e-04, -6.53455275e-04, 3.01471918e-04]
[16.82258106, 18.99248887, 0., 0., 0.]
Correct answer
What will be the output of the following code?:
(10, 2)
(10, 4)
(10, 5)
(10, 6)
Correct answer
(10, 4)
Consider following model:
estimator = SGDClassifier(loss='log', penalty='l2', max_iter=1, warm_start=True, eta0=0.01, alpha=0, learning_rate='constant', random_state=1729)pipe_sgd= make_pipeline(MinMaxScaler(), estimator)Which of the following code snippets will plot the learning curve for training for 100 epochs? Assume necessary imports and the variable names suggest the data they hold/point to.
None of these
Correct answer
If we need quick results during the testing phase, then which classification techniques may not be appropriate?
Correct answer
Following is the code to tune the degree parameter of a polynomial regression model.
Correct answer
The following code produces an output of 0.9125. How is the output expected to change if we increase the max_depth value?:
from sklearn.datasets import load_winefrom sklearn.tree import DecisionTreeClassifierfrom sklearn.model_selection import train_test_splitX,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))Output score is likely to increase.
Output score is likely to decrease.
Output score may increase or decrease.
Output score will remain the same.
Correct answer
Output score is likely to increase.
Consider the following code. How many DecisionTreeClassifier models will be trained internally?
20
75
8
15
40
Correct answer
75
Consider two classifiers as shown in the following block of code:
from sklearn.datasets import load_winefrom sklearn.tree import DecisionTreeClassifierfrom sklearn.model_selection import train_test_splitX,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.2, random_state = 1)clf1 = DecisionTreeClassifier(min_samples_split = 7, min_samples_leaf = 4, random_state = 5)clf1.fit(X_train, y_train)
clf2 = DecisionTreeClassifier(min_samples_split = 4, min_samples_leaf = 2, random_state = 5)clf2.fit(X_train, y_train)What can we say about the depths of the classifiers clf1 and clf2?
depth(clf1) ≥ depth(clf2)
depth(clf1) ≤ depth(clf2)
depth(clf1) = depth(clf2)
Insufficient Information
Correct answer
depth(clf1) ≤ depth(clf2)
Consider the following code:
Correct answers
Consider the following code block with respect to some dataset contained in X and y.
from sklearn.linear_model import linear_regressionfrom sklearn.model_selection import cross_val_scorefrom sklearn.model_selection import ShuffleSplitlin_reg = linear_regression()shuffle_split = ShuffleSplit(n_splits=5, test_size=0.2, random_state=42)score = cross_val_score(lin_reg, X, y, cv=shuffle_split,scoring='-----------------------')Which of the following may be appropriate to be filled in the blank space?
Correct answers
Which of the following models are inherently multiclass models?
KNN
Decision trees
Perceptron
Logistic regression
Correct answers
KNN
Decision trees
Which of the following is/are correct regarding Radius Neighbors Classifier
Only 5 neighbours in the range of some radius are used to compute the label of a sample.
All the neighbours in the range of some radius are used to compute the label of a sample.
It is sensitive to outliers.
It is not sensitive to outliers.
Correct answers
All the neighbours in the range of some radius are used to compute the label of a sample.
It is not sensitive to outliers.
Which options are correct for large datasets that don’t fit into the system’s main memory?
No data preprocessing can be performed.
One hot encoding can not be applied directly or by iteratively learning one hot encoder’s parameters and then applying one hot encoding in batches.
Standard scaling parameters can be learnt iteratively then standard scaling can be applied in batches.
One hot encoding and standard scaling can be applied directly or iteratively.
Correct answers
One hot encoding can not be applied directly or by iteratively learning one hot encoder’s parameters and then applying one hot encoding in batches.
Standard scaling parameters can be learnt iteratively then standard scaling can be applied in batches.
Which of the following class(es) is/are used to instantiate a neural network in Sklearn.
SGDClassifier()
MLPClassifier()
NNClassifier()
MLPRegressor()
Correct answers
MLPClassifier()
MLPRegressor()
Which of the following is correct?
Correct answers
Which of the following processes should be done if we get an imbalanced dataset? Data is imbalanced when the target class has an uneven distribution of label values.
Remove all the minority classes
Remove all the majority classes
Up-sample the minority classes
down-sample the majority classes
Correct answers
Up-sample the minority classes
down-sample the majority classes
Which of the following is true about Naive Bayes algorithm ?
It is primarily used for regression problems
It is primarily used for classification problems
Hyperparameter tuning is required
Hyperparameter tuning is not required
Correct answers
It is primarily used for classification problems
Hyperparameter tuning is not required
Data is continuously being generated
Data is generated every month
Whole data is generated and its in a huge file size
For very small dataset
Correct answers
Data is continuously being generated
Data is generated every month
Whole data is generated and its in a huge file size
Which options are correct for Support Vectors in SVM ?
Support vectors are the data points nearest to the hyperplane
Using these support vectors, we maximize the margin of the classifier.
Using these support vectors, we minimize the margin of the classifier.
None of these
Correct answers
Support vectors are the data points nearest to the hyperplane
Using these support vectors, we maximize the margin of the classifier.
Consider the following block of code:
from sklearn.datasets import load_breast_cancerfrom sklearn.tree import DecisionTreeClassifierfrom sklearn.model_selection import train_test_splitX,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 = 6, min_samples_leaf = 4, 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 be done at node N?
Number of samples at node N = 15. If it is split, it will result in 9 nodes in the left child and 6 nodes in the right child.
Number of samples at node N = 5. If it is split, it will result in 4 nodes in the left child and 2 nodes in the right child.
Number of samples at node N = 7. If it is split, it will result in 4 nodes in the left child and 3 nodes in the right child.
Number of samples at node N = 12. If it is split, it will result in 3 nodes in the left child and 9 nodes in the right child.
Correct answers
Number of samples at node N = 15. If it is split, it will result in 9 nodes in the left child and 6 nodes in the right child.
Number of samples at node N = 7. If it is split, it will result in 4 nodes in the left child and 3 nodes in the right child.
Suppose we want to choose the best value of k in k−means clustering algorithm using Silhouette Coefficient values. Which of the following are required to compute the coefficient value? Note: Labels (cluster number) of the samples are random. There is no functional relationship between a sample and its label
All the samples in the dataset
A few randomly selected samples in the dataset
The number of clusters k, such that k ≥ 2
The number of clusters k, such that k ≥ 1
Correct answers
All the samples in the dataset
The number of clusters k, such that k ≥ 2
Which of the following approach(es) is(are) helpful to find a good value for k in k−means clustering algorithm?
Plotting an Elbow curve
Using GridSearchCV or RandomizedSearchCV for various values of k
Plotting Silhouette coefficient for various values of k
Using k-fold cross validation
Correct answers
Plotting an Elbow curve
Plotting Silhouette coefficient for various values of k
The following line of code create a neural network (assume necessary imports)
The neural network contains 3 hidden layers with 5 neurons in each hidden layer
The neural network contains 5 hidden layers with 3 neurons in each hidden layer
The neural network contains 2 hidden layers with 3 neurons in the second hidden layer
The neural network contains 2 hidden layers with 5 neurons in the first hidden layer
None of the given options are correct
Correct answers
The neural network contains 2 hidden layers with 3 neurons in the second hidden layer
The neural network contains 2 hidden layers with 5 neurons in the first hidden layer
What will be the output of the following code?:
Correct answer: 0.9 (accepted within ±0.05)
The plot below shows a distribution of 200 samples with 2 features in Euclidean space. Suppose we use the K-means clustering algorithm to group these data points into individual clusters. Enter the value of K for which the inertia (Sum Square Error) will be zero. If you conclude, there is no such value for K, then enter -1.
Correct answer: 200