| 148 | return importance |
| 149 | |
| 150 | def plot_variable_importance(importance): |
| 151 | vars = list(importance['test_standard_acc'].keys()) |
| 152 | f_values_standard = [stats['f_value'] for stats in importance['test_standard_acc'].values()] |
| 153 | f_values_robust = [stats['f_value'] for stats in importance['test_robust_acc'].values()] |
| 154 | |
| 155 | x = np.arange(len(vars)) |
| 156 | width = 0.35 |
| 157 | |
| 158 | fig, ax = plt.subplots(figsize=(12, 6)) |
| 159 | rects1 = ax.bar(x - width/2, f_values_standard, width, label='Test Standard Accuracy') |
| 160 | rects2 = ax.bar(x + width/2, f_values_robust, width, label='Test Robust Accuracy') |
| 161 | |
| 162 | ax.set_ylabel('F-value') |
| 163 | ax.set_title('Variable Importance Comparison') |
| 164 | ax.set_xticks(x) |
| 165 | ax.set_xticklabels(vars, rotation=45) |
| 166 | ax.legend() |
| 167 | |
| 168 | plt.tight_layout() |
| 169 | plt.savefig('variable_importance_comparison.png') |
| 170 | plt.close() |
| 171 | |
| 172 | def visualize_data_with_metrics(data, metric_name, output_file): |
| 173 | """ |