Practice
import shap
import xgboost
# Load data
X, y = shap.datasets.boston()
# Train model
model = xgboost.XGBRegressor().fit(X, y)
# Explain the model's predictions using SHAP
explainer = shap.Explainer(model, X)
shap_values = explainer(X)
# What is the shape of shap_values?Solution
Step 1: Understand SHAP output.
SHAP values are calculated for each feature of each instance.Step 2: Determine the shape based on input data.
The dataset has 506 instances and 13 features, so SHAP values will have the shape (506, 13).Final Answer:
Option C -> Option CQuick Check:
SHAP values match data shape: (instances, features). [OK]
Solution
Step 1: Identify system requirements
Real-time systems prioritize speed over marginal accuracy improvements.Step 2: Match model to requirements
YOLO is designed for fast processing, making it suitable for real-time applications.Final Answer:
Option C -> Option CQuick Check:
Real-time = Speed, choose YOLO [OK]
Solution
Step 1: Identify the effect of high alpha in Lasso.
High alpha increases regularization strength, leading to high bias.Step 2: Eliminate wrong options.
Large datasets do not cause overfitting. High complexity increases variance, not bias. Non-normalized features affect scale, not bias directly.Final Answer:
Option D -> Option DQuick Check:
High alpha = high bias in Lasso. [OK]
Solution
Step 1: Understand the domain challenge.
New domains often lack labeled data, making programmatic labeling a flexible choice.Step 2: Evaluate other strategies.
Human annotation is accurate but slow. Weak supervision requires existing data sources, which may not be available. Active learning still requires some initial labeled data.Final Answer:
Option C -> Option CQuick Check:
New domain = Programmatic Labeling [OK]
Solution
Step 1: Consider latency constraints.
Embedded methods integrate feature selection into model training, optimizing for both accuracy and speed.Step 2: Eliminate wrong options.
Filter methods do not consider model performance. Wrapper methods and recursive feature elimination are too slow for real-time systems.Final Answer:
Option B -> Option BQuick Check:
Embedded = fast, integrated. [OK]
