MCPcopy Create free account
hub / github.com/Riley702/enhanced_benchmark_tool / plot_feature_importance

Function plot_feature_importance

src/visualizations.py:31–49  ·  view source on GitHub ↗

Plots feature importance as a horizontal bar chart. Args: feature_importance (dict): Dictionary of feature names and their importance scores.

(feature_importance)

Source from the content-addressed store, hash-verified

29
30
31def plot_feature_importance(feature_importance):
32 """
33 Plots feature importance as a horizontal bar chart.
34
35 Args:
36 feature_importance (dict): Dictionary of feature names and their importance scores.
37 """
38 sorted_importance = sorted(feature_importance.items(), key=lambda x: x[1], reverse=True)
39 features, importance = zip(*sorted_importance)
40
41 plt.figure(figsize=(10, 6))
42 plt.barh(features, importance, color="steelblue")
43 plt.xlabel("Importance Score")
44 plt.ylabel("Features")
45 plt.title("Feature Importance")
46 plt.gca().invert_yaxis()
47 plt.grid(axis="x", linestyle="--", alpha=0.7)
48 plt.tight_layout()
49 plt.show()
50
51
52def plot_confusion_matrix(y_true, y_pred, labels=None):

Callers 1

Calls

no outgoing calls

Tested by 1