Skip to content

Commit 4b7d2cb

Browse files
committed
fix f-string quote nesting for Python 3.11 compatibility
1 parent df93d63 commit 4b7d2cb

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

scripts/generate_publication_report.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ def main() -> None:
9494
print(f'Report saved to {output_path}')
9595
found_models = sum((1 for m in report['models'].values() if m.get('found')))
9696
found_comps = sum((1 for c in report['pairwise_comparisons'].values() if c.get('found')))
97-
print(f'Models: {found_models}/{len(report['models'])} found')
98-
print(f'Pairwise comparisons: {found_comps}/{len(report['pairwise_comparisons'])} found')
99-
print(f'Feature ablation rows: {len(report['feature_ablation'].get('rows', []))}')
100-
print(f'SHAP: {('found' if report['shap'].get('found') is not False else 'pending')}')
97+
print(f"Models: {found_models}/{len(report['models'])} found")
98+
print(f"Pairwise comparisons: {found_comps}/{len(report['pairwise_comparisons'])} found")
99+
print(f"Feature ablation rows: {len(report['feature_ablation'].get('rows', []))}")
100+
print(f"SHAP: {'found' if report['shap'].get('found') is not False else 'pending'}")
101101
if __name__ == '__main__':
102102
main()

scripts/generate_shap_clinical.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@ def main() -> None:
5252
plt.tight_layout()
5353
plt.savefig(output_dir / 'shap_summary_beeswarm.png', dpi=150, bbox_inches='tight')
5454
plt.close()
55-
print(f'Saved beeswarm plot -> {output_dir / 'shap_summary_beeswarm.png'}')
55+
print(f"Saved beeswarm plot -> {output_dir / 'shap_summary_beeswarm.png'}")
5656
plt.figure(figsize=(10, 6))
5757
shap.summary_plot(shap_values, X_test, plot_type='bar', max_display=len(feature_names), show=False)
5858
plt.tight_layout()
5959
plt.savefig(output_dir / 'shap_summary_bar.png', dpi=150, bbox_inches='tight')
6060
plt.close()
61-
print(f'Saved bar plot -> {output_dir / 'shap_summary_bar.png'}')
61+
print(f"Saved bar plot -> {output_dir / 'shap_summary_bar.png'}")
6262
mean_abs_shap = np.abs(shap_values).mean(axis=0).tolist()
6363
metadata = {'model_dir': str(model_dir), 'feature_groups': args.feature_groups, 'split': args.split, 'n_samples': int(len(df_split)), 'feature_names': feature_names, 'mean_abs_shap': {f: float(v) for f, v in zip(feature_names, mean_abs_shap)}, 'note': "XGBoost SHAP values are in original clinical units. No StandardScaler applied — tree-based model is scale-invariant. The tabular_preprocessor.joblib belongs to the multimodal model's tabular branch and must NOT be applied here."}
6464
with open(output_dir / 'shap_metadata.json', 'w', encoding='utf-8') as f:
6565
json.dump(metadata, f, indent=2)
66-
print(f'Saved metadata -> {output_dir / 'shap_metadata.json'}')
66+
print(f"Saved metadata -> {output_dir / 'shap_metadata.json'}")
6767
print('\nMean |SHAP| per feature (descending):')
6868
for feat, val in sorted(zip(feature_names, mean_abs_shap), key=lambda x: -x[1]):
6969
print(f' {feat:30s}: {val:.4f}')

0 commit comments

Comments
 (0)