53 questions pulled from past papers whose wording matches this week's topics, newest first, duplicates removed. Pick your answers, then press Check answers. Figures and answer keys are the originals.
Consider the following two ensemble regression architectures trained on the same dataset:
How do these two models differ in their output strategy to produce the final prediction for a given test instance, and how does adding more estimators affect them?
ensemble1 computes a weighted sum of predictions where later trees have higher weights; ensemble2 takes a simple arithmetic mean of all trees.
ensemble1 reduces variance by averaging independent predictions from 100 trees, meaning increasing n_estimators to 500 will ideally not cause overfitting.
ensemble2 reduces bias sequentially, meaning increasing n_estimators to 500 carries no risk of overfitting.
Both models output predictions by calculating the majority vote across the terminal leaf nodes of all individual base estimators.
Consider the following code snippet that trains a Decision Tree classifier using scikit-learn:
A node in the trained decision tree is split only if both of the following conditions are satisfied: • The node contains at least min_samples_split samples. • Each child node created after the split contains at least min_samples_leaf samples. Assume node (N) is a non-leaf node being considered for splitting. In which of the following cases will the split at node (N) be allowed?
Node (N) contains 15 samples. After splitting, the left child has 9 samples and the right child has 6 samples.
Node (N) contains 6 samples. After splitting, the left child has 4 samples and the right child has 2 samples.
Node (N) contains 12 samples. After splitting, the left child has 3 samples and the right child has 9 samples.
Node (N) contains 8 samples. After splitting, the left child has 4 samples and the right child has 4 samples.
You are training a RandomForestRegressor on a dataset with 20 features and 10,000 samples. Consider the following code:
Which of the following statements is TRUE about how this Random Forest model will behave?
With bootstrap=True, every tree sees the entire dataset, but the samples are shuffled randomly for each tree.
The forest will use all 20 features for each split, but only 5 trees out of the 200 will be trained on bootstrap samples.
Setting max_features=5 means only 5 trees out of 200 will use feature subsets, while the rest use all features.
Each tree will consider only 5 randomly chosen features when looking for the best split at every node.
Consider following parameter grid for regression with RandomForest:
Consider following parameter grid for regression with RandomForest: How many unique combinations of hyperparameters are there in the above parameter grid?
Consider below statements and choose the correct option: Statement1:The bagging technique combines multiple models trained on different subsets of data Statement2:The Boosting technique trains the model Parallelly, focusing on the error made by the other model.
You’re working on a dataset containing customer purchase data, and you want to segment the customers into distinct groups based on their purchasing behavior. Each data point represents a customer and includes features like “Total Amount Spent” and “Number of Items Purchased.” Which algorithm is suitable for this scenario?
Consider the following statements about SGDClassifier: 1. It can be used to train a model on large dataset that doesn’t fit in main memory 2. It can emulate a KNN model 3. It can emulate a decision tree model 4. It can emulate a perceptron Choose the correction option(s)
Following is the code to tune the n_estimators parameter of a Bagging Classifier model.
Following is the code to tune the n_estimators parameter of a Bagging Classifier model.
Consider the following code. How many DecisionTreeClassifier models will be trained internally?
Consider the following code. How many DecisionTreeClassifier models will be trained internally?
Consider following statements regarding a decision tree model? 1. It is a parametric model. 2. It has a tendency to overfit if allowed to grow unconditionally. 3. It can be used for regression, classification and clustering problems. 4. It is one of the easiest machine learning models to interpret. 5. For classification problems, decision tree’s loss function is same as evaluation metric. Choose the option with all the correct statements:
Lata wants to train a bagging regressor with following specifications: 1. Base estimator as linear regressor with default parameter values. 2. 80% of the data is used to create a bag of samples. 3. Create subsets of training set without replacement. 4. Take half the features when creating subsets of data. 5. Train the model on training set. 6. Print score on test set. Which of the following code blocks will correctly execute Lata’s task? [Note: Assume necessary imports and variables for training and test sets.]
You have a binary classification problem to solve with following information: 1. All features are numircal. 2. The dataset has size of 80 GB. 3. The data has to be preprocessed. 4. After data preprocessing, train the model with gradient descent or its variations. Which of the following will perform the above task?
Perform one hot encoding followed by training with LogisticRegression model(sklearn.linear_model).
Perform standard scaling followed by asklearn.neighbors.KNeighborsClassifier model.
Perform min-max scaling followed by a sklearn.tree.DecisionTreeClassifiermodel.
Perform max-absolute scaling followed by asklearn.linear_model.SGDClassifier model.
Brajesh wants to tune hyper parameters of an AdaBoost model for a classification problem with following specifications: 1. Base estimator as Decision trees classifier with max_depth=1. 2. Number of estimators range from 30 to 40 (both inclusive) at the interval of 1. 3. Cross validation = 5. 4. Learning rate must vary between 0.2 to 2.0 (both inclusive) at the intervals of 0.2. 5. Train the best model on the entire training set. 6. Print score on test set. Which of the following code blocks will correctly execute Brajesh’s task? [Note: Assume necessary imports and variables for training and test sets.]
Consider following statements regarding a decision tree model: 1. It is a non-parametric model. 2. It has a tendency to underfit if allowed to grow unconditionally. 3. It can be used for regression and classification problems only, but not for clustering. 4. It is one of the most difficult machine learning models to interpret. 5. For regression problems, decision tree’s loss function and evaluation metric can be same. Choose the option with all the correct statements:
You have a regression problem to solve with following information: 1. All features are numerical. 2. The dataset has size of 40 GB. 3. The data has to be preprocessed. 4. After data preprocessing, train the model with gradient descent or its variations. Which of the following will perform the above task?
Perform one hot encoding followed by training with LinearRegression model(from sklearn.linear_model).
Perform standard scaling followed by training with KNeighborsRegressormodel (from sklearn.neighbors).
Perform min-max scaling followed by training with DecisionTreeRegressormodel (from sklearn.tree).
Perform min-max scaling followed by training with SGDRegressor model (fromsklearn.linear_model).
Rajesh wants to tune hyper parameters of an AdaBoost model for a classification problem with following specifications: 1. Base estimator as Decision trees classifier with max_depth=1. 2. Number of estimators range from 10 to 20 (both inclusive) at the interval of 1. 3. Cross validation =4. 4. Learning rate must vary between 0.1 to 1.0 (both inclusive) at the intervals of 0.1. 5. Train the best model on the entire training set. 6. Print score on test set. Which of the following code blocks will correctly execute Rajesh’s task? [Note: Assume necessary imports and variables for training and test sets.]
Asha wants to train a bagging classifier with following specifications: 1. Base estimator as k nearest neighbour classifier with default parameter values. 2. 70% of the data is used to create a bag of samples. 3. Create subsets of training set with replacement. 4. Take all features when bootstrapping. 5. Train the model on training set. 6. Print score on test set. Which of the following code blocks will correctly execute Asha’s task? [Note: Assume necessary imports and variables for training and test sets.]
Consider the following block of code and mark all possible correct options.
Consider the following block of code and mark all possible correct options.
Given model uses majority voting rule to predict class labels.
Given model predicts the class labels based on the argmax of the sums of thepredicted probabilities.
Setting flatten_transform =True with voting=’soft’ will flatten the output shapeof transform.
For the following block of code, we get the output as 0.9875. How would the output change if we decrease max depth value ?:
For the following block of code, we get the output as 0.9875. How would the output change if we decrease max depth value ?:
Output score will definitely increase.
Output score will definitely decrease.
Output score may decrease or remain the same.
Code will throw an error because max_depth can’t be less than 6.