An importance score estimates how strongly an input feature contributes to a model’s predictions. In a random forest, it reflects the feature’s contribution to impurity reduction across the trees: features producing consistently better splits receive higher scores. section 6.4.4 section 6.5
Interpret scores as relative contributions within the fitted model:
- Higher values indicate features with greater influence on the model’s predictions; lower values indicate less influence. section 6.4.4
- Aggregate scores across the forest rather than inspecting individual trees, making feature ranking practical for ensembles. section 6.4.4
- Use rankings to improve transparency and guide data preprocessing or feature engineering. section 6.4.4
Fourth-down conversion model
A RandomForestClassifier ranks features by descending importance. In the displayed analysis, TO_GO and PLAY_TYPE account for approximately 80% of the model’s predictive power. A score of 0.6 therefore indicates substantially more relative influence than a score of 0.1. section 6.1 section 6.4.4
>>> importances = rf.feature_importances_ #1
>>> features = X.columns #2
>>> indices = np.argsort(importances)[::-1] #3
>>> sorted_features = features[indices] #4
>>> sorted_importances = importances[indices] #5
>>> plt.figure() #6
>>> plt.bar(sorted_features, sorted_importances) #7
>>> plt.xlabel('Feature') #8
>>> plt.ylabel('Feature Importance') #9
>>> plt.title('Feature Importance in \
>>> RandomForestClassifier') #10
>>> plt.tight_layout() #11
>>> plt.show() #12
Extract feature_importances_, sort features with NumPy, and visualize their relative scores as a Matplotlib bar chart. section 6.4.4





