Feature Importance Decision Tree

[Solved] Feature Importance Decision Tree | Shell - Code Explorer | yomemimo.com
Question : Feature importance Decision Tree

Answered by : elisabeth-l-engering

# Plot importance of variables
feature_importance = model.feature_importances_
sorted_idx = np.argsort(feature_importance) # Sort index on feature importance
fig = plt.figure(figsize=(20, 15)) # Set plot size (denoted in inches)
plt.barh(range(len(sorted_idx)), feature_importance[sorted_idx], align='center')
plt.yticks(range(len(sorted_idx)), np.array(X_test.columns)[sorted_idx])
plt.xlabel("Feature importance") # Add x axis
plt.ylabel("Feature") # Add y axis

Source : | Last Update : Mon, 11 Jul 22

Answers related to feature importance decision tree

Code Explorer Popular Question For Shell