Practice
1. In the context of MLflow, which component is primarily responsible for storing and managing model artifacts?
easy
Solution
Step 1: Identify the role of each MLflow component
MLflow Registry is designed to store and manage model artifacts.Step 2: Eliminate wrong options
MLflow Tracking logs metrics and parameters, MLflow Projects handles reproducibility, and MLflow Models deals with model packaging.Final Answer:
Option A -> Option AQuick Check:
Registry = Artifacts [OK]
Hint: Registry = Artifacts [OK]
Common Mistakes:
2. In the context of feature engineering, which of the following techniques is most suitable for handling categorical variables with high cardinality?
easy
Solution
Step 1: Identify the challenge with high cardinality.
High cardinality in categorical variables can lead to a large number of features when using one-hot encoding.Step 2: Evaluate each option.
One-hot encoding (A) creates too many features. Label encoding (B) imposes an ordinal relationship. Binary encoding (D) reduces dimensionality but not as effectively as target encoding (C), which uses the target variable to encode categories, reducing dimensionality and capturing information.Final Answer:
Option C -> Option CQuick Check:
Target encoding handles high cardinality efficiently. [OK]
Hint: Target encoding handles high cardinality efficiently. [OK]
Common Mistakes:
3.
import numpy as np
from sklearn.feature_selection import SelectKBest, f_classif
X = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
y = np.array([1, 0, 1])
selector = SelectKBest(score_func=f_classif, k=2)
X_new = selector.fit_transform(X, y)
print(X_new)What does the above code output?easy
Solution
Step 1: Understand SelectKBest.
SelectKBest selects the top k features based on the highest scores from the scoring function.Step 2: Determine the output.
f_classif scores features based on ANOVA F-value. Here, features 2 and 3 have the highest scores.Final Answer:
Option A -> Option AQuick Check:
Top k features by score. [OK]
Hint: SelectKBest picks top k features by score. [OK]
Common Mistakes:
4. A machine learning model is consistently overfitting on a dataset. What is the most likely cause?
medium
Solution
Step 1: Identify symptoms of overfitting.
Overfitting occurs when a model learns noise instead of the signal.Step 2: Determine the cause related to model complexity.
Too many parameters can lead to overfitting by capturing noise.Final Answer:
Option B -> Option BQuick Check:
Overfitting often means too complex a model. [OK]
Hint: Overfitting often means too complex a model. [OK]
Common Mistakes:
5. You are tasked with evaluating a regression model for a financial application where large errors are particularly costly. Which metric should you choose and why?
hard
Solution
Step 1: Consider the cost of large errors.
MSE penalizes larger errors more due to squaring, making it suitable for costly errors.Step 2: Eliminate wrong options.
MAE does not penalize large errors enough. RMSE is similar to MSE but does not emphasize large errors as much. Huber Loss is more for outliers, not large errors specifically.Final Answer:
Option C -> Option CQuick Check:
MSE penalizes large errors heavily. [OK]
Hint: MSE penalizes large errors heavily. [OK]
Common Mistakes:
