Test 05 - Compare Matrices & Feature Analysis
Purpose
Compare the matrix produced by the silent/external run against a reference matrix and generate feature-level difference reports and visualizations (including Shap/ButWhy analyses). The test produces interactive HTML reports (Plotly) and global/single-feature explainability outputs for inspection. This is similar to Silent Run Test (no labels) - 05. Now we loaded the repository and have outcome. The stratification and comparasing can also stratify by the outcome.
Required Inputs
From configs/env.sh and the test invocation environment:
WORK_DIR: Working folder where outputs will be writtenMODEL_PATH: Path to the model used for generating matrices (by default pulled from${FIRST_WORK_DIR}/model/model.medmdl)REFERENCE_MATRIX: CSV path to the reference matrix to compare againstCMP_FEATURE_RES: Comma-separated feature resolution definitions used for feature-subsetting in the no-overfitting run
How to Run
From your TestKit folder, execute:
Or include as part of the full suite:
Check ${WORK_DIR}/compare and ${WORK_DIR}/compare.no_overfitting for results and HTML visualizations.
What This Test Does
- Calls TestModelExternal to compare the model applied to the test repository against the
REFERENCE_MATRIX. Outputs are written to${WORK_DIR}/compare.- Uses sampling limits (
MAX_SIZE=500000) and various subsampling parameters to limit memory use. - Produces feature-level
shapley_report.tsvunder${WORK_DIR}/compare.
- Uses sampling limits (
- Runs
feature_importance_printer.pyto build a global and single-feature HTML visualizations under${WORK_DIR}/compare/ButWhy. - Runs a second comparison under
compare.no_overfittingwith a restricted feature set derived fromCMP_FEATURE_RESto check results when removing possibly overfitted features. - Fixes plotly.js script tag paths in output HTML files so they link correctly from the final docs location.
Output Location
- Primary comparison outputs:
${WORK_DIR}/compare - No-overfitting comparison outputs:
${WORK_DIR}/compare.no_overfitting - Feature explainability HTML reports:
${WORK_DIR}/compare/ButWhyand${WORK_DIR}/compare.no_overfitting/ButWhy - Shapley reports:
${WORK_DIR}/compare/shapley_report.tsv
How to Interpret Results
- Open
${WORK_DIR}/compare/and use same methodology as in Test 05 in Silent Run - Review
${WORK_DIR}/compare/compare_rep.txtfor a textual summary of the comparison. - Use the
ButWhyHTMLs to understand global and single-feature contributions and check whether important features behave similarly between the silent run and the reference. - The
compare.no_overfittingrun restricts features based onCMP_FEATURE_RESand can reveal whether top differences are driven by a small set of features.
Common failure modes and suggestions
- Large matrices exceed memory or time limits:
- Adjust
MAX_SIZEand subsample parameters in the script to reduce processing size.
- Adjust
- Missing
TestModelExternalorfeature_importance_printer.pyutilities:- Ensure these are available on PATH.
- Plotly template or
plot.pynot found:- Confirm
plot.pyexists in PATH and that itstemplates/plot_with_missing.htmlfile is reachable.
- Confirm
- Incorrect
CMP_FEATURE_RESformatting:- The script expects comma-separated tokens like
FeatureA:0.1,FeatureB:10-ensure formatting matches.
- The script expects comma-separated tokens like
Test Results Review
Primary files to inspect after running this test:
${WORK_DIR}/compare/compare_rep.txt${WORK_DIR}/compare/shapley_report.tsv${WORK_DIR}/compare/ButWhy/Global.html${WORK_DIR}/compare.no_overfitting/ButWhy/Global.html