Practice
from sklearn.model_selection import KFold
kf = KFold(n_splits=5)
for train_index, test_index in kf.split(range(100)):
print(len(test_index))Solution
Step 1: Calculate the number of samples per fold.
100 samples divided by 5 splits results in 20 samples per fold.Step 2: Eliminate wrong options.
25 samples per fold (B) is incorrect, 6 outputs (C) is incorrect, 4 outputs (D) is incorrect.Final Answer:
Option A -> Option AQuick Check:
100 samples, 5 splits = 20 per fold. [OK]
Solution
Step 1: Identify the metric for node impurity.
Gini Impurity is specifically used to measure the impurity of a node in decision trees.Step 2: Eliminate wrong options.
Entropy is used for information gain, Mean Squared Error is for regression tasks, and Information Gain is a criterion for splitting, not impurity.Final Answer:
Option B -> Option BQuick Check:
Gini measures impurity in nodes. [OK]
Solution
Step 1: Understand the purpose of pretraining.
Pretraining allows the model to learn general features from a large dataset.Step 2: Eliminate wrong options.
Pretraining ensures the model learns task-specific features from the start. is incorrect because pretraining focuses on general, not task-specific, features. Pretraining reduces the need for any further training on the task-specific dataset. is incorrect because fine-tuning is still necessary. Pretraining is only useful for models with a large number of parameters. is incorrect because pretraining is beneficial regardless of model size.Final Answer:
Option A -> Option AQuick Check:
Pretrain for general features, fine-tune for specific tasks. [check]
Solution
Step 1: Identify common convergence issues
A high learning rate can cause the model to overshoot the minimum, preventing convergence.Step 2: Eliminate wrong options
A small dataset (B) or too many features (C) might affect performance but not convergence. Initial weights being zero (D) is not a convergence issue.Final Answer:
Option B -> Option BQuick Check:
High learning rate can prevent convergence. [OK]
Solution
Step 1: Address class imbalance and overfitting
Class weights help balance the dataset, and early stopping prevents overfitting by halting training when validation performance stops improving.Step 2: Eliminate wrong options
Use SMOTE to oversample the minority class and increase model complexity. increases complexity, risking overfitting, Downsample the majority class and increase the learning rate. may lead to instability, and Use a simpler model with no regularization. lacks regularization, increasing overfitting risk.Final Answer:
Option C -> Option CQuick Check:
Class weights + early stopping = balanced, robust model [OK]
