Which method directly measures the impact of each feature on the prediction error by randomly shuffling its values and observing the change in model performance?
Think about a method that tests how much the model's error increases when a feature's information is disrupted.
Permutation importance measures feature importance by shuffling feature values and checking how much the model's error increases, showing the feature's impact on predictions.
What is the output of the following Python code using scikit-learn's RandomForestRegressor to get feature importances?
from sklearn.ensemble import RandomForestRegressor import numpy as np X = np.array([[1, 2], [3, 4], [5, 6], [7, 8]]) y = np.array([1, 3, 5, 7]) model = RandomForestRegressor(random_state=0) model.fit(X, y) importances = model.feature_importances_ print(np.round(importances, 2))
Random forests usually assign importance based on how much each feature reduces error across trees.
The output shows the relative importance of each feature. Here, the second feature has higher importance, approximately 0.7, and the first about 0.3.
You want a regression model that provides clear, direct coefficients to interpret feature importance easily. Which model should you choose?
Look for a model where feature importance is given by simple coefficients.
Linear regression provides coefficients that directly show the effect of each feature on the output, making it easy to interpret feature importance.
Which metric change best indicates a feature is important when removed from a regression model?
Think about how prediction error changes when a feature is removed.
If removing a feature causes the mean squared error to increase significantly, it means the feature was important for accurate predictions.
You trained a linear regression model but the feature importance (coefficients) are all zero. What is the most likely cause?
Consider what happens if the target does not change at all.
If the target variable has no variance, the model cannot learn any relationship, resulting in zero coefficients for all features.
