Skip to content

SaveDiagnosticResults

Utilities for serialising and saving diagnostic outputs and HTML reports.

save_test_results(results, test_name, save_root, feature_names=None, report_date=None, report_name=None)

Save results from a single diagnostic test into a CSV inside a timestamped directory.

  • results: Accepts either:
    • dict mapping comparison_key -> scalar (overall single-number results) or
    • dict mapping comparison_key -> 1D array-like of per-feature results
    • or a DataFrame already (written directly)
    • or a mapping of comparison_key -> dict (then flattened into a DataFrame row)
  • test_name: name used for the CSV filename (e.g. 'Levene_Test' or 'KS_Test')
  • save_root: folder under which DiagnosticResults_YYYY-MM-DD/ will be created
  • feature_names: optional list of column names for featurewise results (lowercase 'feature_names') if None and an array is present, a fallback 'feature_0'.. will be used.
  • report_date: optional 'YYYY-MM-DD' to control directory naming (your report timestamp)

Minimal and defensive: doesn't change your results structure, only converts it into DataFrame(s) and writes one CSV named f"{test_name}.csv".

Usage

Programmatic example:

from DiagnoseHarmonisation.SaveDiagnosticResults import save_report
save_report(report_object, out_path='diagnostic_report.html')

This module contains helpers used by the CLI and GUI to persist analysis outputs.