Skip to content

fix: 5 production bugs across AutoML pipeline, config, CV, logging, and explainability#44

Merged
TurboRx merged 9 commits intomainfrom
copilot/fix-bugs-and-improve-performance
Feb 22, 2026
Merged

fix: 5 production bugs across AutoML pipeline, config, CV, logging, and explainability#44
TurboRx merged 9 commits intomainfrom
copilot/fix-bugs-and-improve-performance

Conversation

Copy link
Contributor

Copilot AI commented Feb 22, 2026

  • Explore codebase and run tests (all 142 pass)
  • Fix core.py: TPOT metrics/model mismatch
  • Fix evo_learn/config.py: from_yaml crashes on unknown YAML keys
  • Fix evo_learn/logging_utils.py: log_experiment_end crashes with non-float metric values
  • Fix evo_learn/cross_validation.py: KeyError when roc_auc missing from some folds
  • Fix evo_learn/explainability.py (initial): feature name mismatch and wrong data source in SHAP plots
  • Fix evo_learn/explainability.py (follow-up): use iloc for positional indexing in explain_prediction; bound explain_model loop to sampled SHAP row count
  • Fix evo_learn/explainability.py (follow-up 2): pass features=self._X_test_transformed to shap.summary_plot
  • Fix evo_learn/explainability.py (follow-up 3): resolve base_values to a scalar in explain_prediction — multi-class explainers return array-like expected_value; select the element matching class_idx to prevent shape mismatches in waterfall plots
  • Run all 142 tests – all pass
  • CodeQL scan – 0 alerts

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- core.py: fix TPOT metrics/model mismatch by fitting the full
  pipeline once and computing metrics from the saved pipeline
- evo_learn/config.py: filter unknown YAML keys in from_yaml to
  prevent TypeError on unexpected config entries
- evo_learn/logging_utils.py: handle non-float metric values in
  log_experiment_end with graceful format fallback
- evo_learn/cross_validation.py: fix KeyError from conditional
  roc_auc key by intersecting metric keys across all folds
- evo_learn/explainability.py: fix feature name mismatch in
  plot_summary/plot_feature_importance and wrong data source in
  explain_prediction by storing transformed test data and names

Co-authored-by: TurboRx <187360786+TurboRx@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bugs and enhance existing features for robustness fix: 5 production bugs across AutoML pipeline, config, CV, logging, and explainability Feb 22, 2026
Copilot AI requested a review from TurboRx February 22, 2026 06:26
@TurboRx TurboRx requested a review from Copilot February 22, 2026 06:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes 5 production bugs across the AutoML pipeline that caused crashes, silent errors, and metric/model mismatches. The fixes improve correctness and reliability of core functionality including TPOT model training, configuration loading, cross-validation aggregation, logging formatting, and SHAP explainability.

Changes:

  • Fixed TPOT pipeline to ensure metrics and saved model describe the same fitted object (previously metrics came from raw-data fit, model from preprocessed-data refit)
  • Added defensive filtering in YAML config loading to handle unknown keys gracefully instead of crashing
  • Changed CV metric aggregation to use set intersection, preventing KeyError when metrics like roc_auc are conditionally computed
  • Added try-except fallback for non-float metric values in logging to prevent TypeError crashes
  • Fixed SHAP feature name extraction to use transformed feature names that match SHAP values dimensions

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
core.py Unified TPOT training pipeline - create pipeline first, fit once, compute metrics and save the same model. Added defensive try-except for predict_proba with shape validation.
evo_learn/config.py Added dataclass field filtering when loading YAML configs to ignore unknown keys with warnings instead of raising TypeError.
evo_learn/cross_validation.py Use set intersection across folds to aggregate only metrics present in all folds, fixing KeyError from conditionally-computed metrics like roc_auc.
evo_learn/logging_utils.py Added try-except fallback when formatting metric values, preventing TypeError when metrics are strings or other non-float types.
evo_learn/explainability.py Store transformed test data and feature names to ensure SHAP plots use correct feature names matching transformed dimensions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@TurboRx
Copy link
Owner

TurboRx commented Feb 22, 2026

@copilot apply changes based on the comments in this thread

…plain_model loop to sampled SHAP rows

- explain_prediction: switch from label-based indexing (X[sample_idx])
  to iloc for DataFrames so non-sequential indices from .sample() don't
  cause KeyError
- explain_model: iterate over range(min(3, n_shap_rows)) instead of
  range(min(3, len(X_test))) so indices are always valid within the
  (potentially sampled) _X_test_transformed

Co-authored-by: TurboRx <187360786+TurboRx@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

TurboRx and others added 2 commits February 22, 2026 12:13
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@TurboRx
Copy link
Owner

TurboRx commented Feb 22, 2026

@copilot apply changes based on the comments in this thread

… coloring

shap.summary_plot requires the actual feature data matrix (features=)
to color points in dot/violin plots by feature value. Previously only
feature_names was passed, which broke feature-value coloring. Now
passes features=self._X_test_transformed alongside feature_names.

Co-authored-by: TurboRx <187360786+TurboRx@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@TurboRx
Copy link
Owner

TurboRx commented Feb 22, 2026

@copilot apply changes based on the comments in this thread

…ected_value

In explain_prediction, when the explainer returns a list of SHAP values
(multi-class), expected_value is also array-like (one per class).
Passing the full array as base_values caused shape mismatches and
incorrect waterfall plots.

Now resolves base_values to a scalar by selecting the element matching
the chosen class_idx (1 for binary/positive class, clamped to the
array length), with a fallback to the first element when class_idx is
unavailable or out of range.

Co-authored-by: TurboRx <187360786+TurboRx@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@TurboRx TurboRx requested a review from Copilot February 22, 2026 07:51
@TurboRx TurboRx added bug Something isn't working enhancement New feature or request python Pull requests that update python code labels Feb 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@TurboRx TurboRx marked this pull request as ready for review February 22, 2026 07:55
@TurboRx TurboRx merged commit 030b684 into main Feb 22, 2026
11 of 28 checks passed
@TurboRx TurboRx deleted the copilot/fix-bugs-and-improve-performance branch February 22, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants