Repository navigation
Use full training labels for holdout classification scoring - #1642
Aryan R. Ganjoo (AryanRG) wants to merge 26 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Sampled classifiers can still fail log-loss scoring, and each trial unnecessarily recomputes the full training class set.
2 open issues
What changed in this PR
Updates AutoML holdout classification scoring to use the full training class set when validation or sampled training data omits a class.
Changes:
- Passes full training targets into trial scoring.
- Infers holdout labels while preserving explicit overrides and token-classification behavior.
- Adds regression tests for missing classes, time splits, custom metrics, and sampling.
| File | Description |
|---|---|
| test/automl/test_holdout_labels.py | Adds holdout label regression tests. |
| flaml/automl/state.py | Passes full training targets to scoring. |
| flaml/automl/ml.py | Infers classification labels for holdout metrics. |
Review effort: Balanced
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Overall review at efb0e90208c145cd4780bcd2b329b2dfbd7f3106: changes requested. The ordinary missing-validation-class fix works, including independently checked string labels and binary single-class validation. One sampled-scoring P2 remains.
P2 - Align sampled probability columns with the full label set. Using the PR's 3,000-row rare-class fixture, change validation to classes [0, 1], use built-in metric="log_loss", and enable log_training_metric=True. A sampled model has two probability columns, but this change supplies labels [0, 1, 2]. Validation scoring becomes infinite; the training-score call then raises an uncaught ValueError and aborts the public AutoML.fit call. The exact pre-change scoring function, exercised through the same common framework with only the new keyword discarded, completes with loss 0.43185208871658 and model classes [0, 1]; the current call raises the class-count mismatch. This comparison does not claim an entirely old package installation.
Please preserve full-class semantics while aligning probability columns for both validation and training scoring, and add a sampled built-in log-loss test with training metrics enabled. The existing custom-F1 test avoids probability columns. Balanced Copilot independently reported this in the existing discussion; no duplicate inline is being added.
P3 - Preserve the existing string-task helper path. compute_estimator still accepts Union[str, Task]. With task="classification" and an explicit built-in estimator_class, the old helper succeeds but the new guard raises AttributeError: 'str' object has no attribute 'is_classification'. Normalize the supported string form before calling Task methods. This is lower priority: the sole in-repository caller already supplies a Task object, so it is not a second claim that normal public AutoML construction fails.
Validation: all 5 new tests and 4 existing LGBM/LRL1 CV/underlying-model reproducibility cases passed. Independent real public scoring and six isolated label-routing checks also passed; the sampled public regression and string-helper incompatibility were separately reproduced. Approval is withheld for the verified public regression.
Posted by thinkall-agent-auto-reviewer
|
Thanks Li Jiang (@thinkall), I've fixed the sampled log-loss crash and the string-task helper. Labels are now cached per fit, with regression coverage for both validation and training scoring. |
|
@microsoft-github-policy-service agree |
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Overall review at dd0c080b4f40600441ec26f6ccc042f279cfc9d0: changes requested for one remaining P2 in callable probability scoring.
The original built-in log-loss/training-metric failure is fixed, the string-task helper no longer raises the reported attribute error, and the cache refreshes across class-set changes and clears for regression. All 17 targeted repository tests passed. The six independent Medium review-code lenses and driver checks are complete; their original findings/severities are retained separately from this adjudicated public result.
P2 - Preserve the documented custom log-loss workflow as well as the built-in metric. The new aligner runs only in the string-metric branch. The published custom metric still calls log_loss(y, estimator.predict_proba(X), labels=labels). With a sampled two-class estimator and full labels [0, 1, 2], that callback raises the same class/probability-count ValueError and aborts AutoML.fit.
Using the PR's seed-1 fixture (3,000 rows, 40 rare-class examples), validation classes [0, 1], min_sample_size=50, sample=True, auto_augment=False, estimator_list=["lgbm"], and two trials, the exact released-main scoring module in the common framework completes the published callback with finite loss 0.5884176913322716. Current code aborts on the first callback: 50 training rows, estimator classes [0, 1], supplied labels [0, 1, 2]. This reference-module comparison does not claim an entirely old package installation. The latest corrective commit leaves the defect in place even though it predates that small delta; it is introduced by the whole PR versus released main.
Please keep callable probability outputs and their supplied class metadata consistent, preserve this previously valid documented workflow, and add a sampled regression using that recipe. A positive Copilot recommendation and passing built-in-only tests do not resolve the independently reproduced failure.
A lower-priority defensive-copy concern is also confirmed: a callback that mutates the cached label array changes later sequential trials, whereas the prior implementation supplied fresh inferred labels per trial. Keep that P3 hardening concern separate from the public workflow P2 above.
Posted by thinkall-agent-auto-reviewer
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Reviewed the correction at 93b8931ae2682918cb68c9e74076540fa4b713e0. The earlier documented-callback P2 and label-mutation concern are fixed: the original public callback now matches released-main reference loss 0.5884176913322716, and repeated array/list/Series callbacks plus a real six-call CV fit preserve label isolation. All 19 targeted tests passed. The Low harness is CLEAN for this localized delta, not a whole-PR approval.
One remaining P2 - Handle a valid one-class LightGBM sample before the probability-width fallback. A fitted LightGBM classifier can have classes_ == [0] yet return two probability columns. _align_log_loss_probabilities returns those columns unchanged because their width differs from len(classes_), but scoring still receives the full three labels. Both sampled trials become infinite loss, and public AutoML.fit returns without a best model.
Reproduction uses 3,000 targets initially zero, with rows 1500 and 2500 set to classes 1 and 2; Gaussian features from RandomState(81); validation labels alternating 0/1; metric="log_loss", estimator_list=["lgbm"], two trials, min_sample_size=50, sample=True, auto_augment=False, retrain_full=False, and log_training_metric=False. The exact released-main scoring module in the common framework returns a trained model with finite loss 17.2693881956416. Current code returns best_loss=inf and model=None. This is a reference-module comparison, not an entire old-package installation.
An observation-only wrapper confirms both current trials have classes [0], labels [0,1,2], and unchanged (300,2) input/output probabilities. An independent zero-filled full-class oracle is finite (18.021826694558573), so preserving the full-class metric need not discard these trials. Handle this supported backend boundary, or ensure appropriate class coverage before evaluation, and add a one-class-sample regression alongside the two-class case.
This is a remaining whole-PR alignment defect, not a claim that the callback guard introduced it. No exception from AutoML.fit is claimed here: the failure is specifically infinite loss and no model. A positive Balanced Copilot recommendation does not resolve that independently reproduced P2, so approval remains withheld.
Posted by thinkall-agent-auto-reviewer
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Overall reassessment at e3046451d9201ac966a8708631e1a3df2b74b4f5: the reported code fixes are verified; approval is withheld for external gates.
The original one-class public counterexample now returns trained models with finite losses for LightGBM, XGBoost and xgb_limitdepth. Losses match independent dtype-correct full-class sklearn oracles. Raw/wrapped classifiers, numeric/string label placement and input immutability are covered; legacy binary and unknown-backend behavior remain intact. The documented callback again returns its expected finite loss and legacy label inference.
I freshly reread the complete main-to-head production/test changes, not only the last corrective hunk. The scoped Low review-code harness is CLEAN (actual gpt-6.1-sol), 43 targeted tests passed, and full all-file pre-commit passed before the local evidence commit. No confirmed blocking code issue remains in this PR. Both earlier signed P2 discussions are now resolved after reproducing and verifying their fixes; no other reviewer's thread was changed.
Approval is not submitted: applicable check contexts are not all successful; actual Build: in_progress/None.
Posted by thinkall-agent-auto-reviewer
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Overall review of the complete current PR at e3046451d9201ac966a8708631e1a3df2b74b4f5: approved.
I freshly reassessed the complete main-to-head production/test changes rather than treating the last small repair as whole-PR clearance. Full-label holdout scoring, per-fit cache reset, explicit overrides, legacy callable behavior and callback isolation remain consistent. Sampled one-class LightGBM and both XGBoost paths now return finite trained models with correct full-class losses, and regular sampled-class mapping preserves class order and raw input probabilities. The earlier independently reproduced P2s are resolved; no blocking code issue remains.
Validated exact-head review-code evidence was reused (Low, actual gpt-6.1-sol), including the prior 43 passing tests and native dtype-correct oracle/callback checks. These are unchanged-source results, not a claim of a new model or test run. My two earlier signed P2 discussions were resolved only after their exact counterexamples passed.
Fresh same-head gates now confirm all discussions resolved, an explicit Balanced Copilot approval recommendation, every applicable check successful, and the actual Build/docs/formatting workflows successfully completed. The conditional gh-release skip is specifically justified by the unchanged workflow's pull_request exclusion.
Posted by thinkall-agent-auto-reviewer
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Current selected-scope review at author head ef930f1e4bc8df95875ef40dbccb6fd11b326cc2.
The newly added native automl.predict(X_val) assertion restores useful HistGB label coverage and passes on both source-pinned Python 3.10/3.13 stacks; the other 156 tests were deselected per run.
One low test-quality note remains: np.testing.assert_array_equal(20, np.full(300,20)) accepts the scalar. I independently confirmed this on NumPy 1.26.4 and 2.3.3, while np.array_equal rejects that shape mismatch. Using a shape-aware comparison would ensure the assertion checks one prediction per row. This is an assertion-robustness note, not a reproduced scalar-return bug in the current estimator.
This review covers only that new test assertion and the small foreign doc/Hydra baseline, not a new whole-PR High review or verification of every manually resolved production path. Required historical whole coverage remains 7/8 and the run-wide recovery/followup allowance is exhausted. Passing this narrow test cannot supply the missing independent evidence.
Thinkall-authored PRs and their imported patch contents were excluded from the selected review diffs and received no review. Current validation totals 38 Python tests and 15 selected foreign baseline checks; this does not claim the full platform/version matrix, a website build or artifact-service execution. Every original finding and older High/whole/provider/safety bound is retained. Review artifacts remain in detached local-only commits and are never pushed to this PR.
Current check rollup: FAILURE; unresolved threads: 1. This formal commented review is not an overall approval.
Posted by thinkall-agent-auto-reviewer
There was a problem hiding this comment.
🟡 Changes recommended
Forecast log replay can fail on fresh instances due to uninitialized class metadata, while an unconditional XGBoost import breaks unrelated learners when that optional dependency is absent.
2 open issues
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because MLflow-exported pipelines can omit probability columns for unsampled classes, causing deployed probabilities to differ from the evaluated AutoML model.
1 resolved since last review
Review effort: Balanced
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
New author correction only, reviewed at 7659aa2ad630cd135205317f1174a3d172ce5e0f.
The optional-XGBoost import/type-tuple correction and the two forecast replay state resets pass 64 meaningful checks across the pinned Python/pandas stacks. Fresh owned child processes really remove optional backends before import, and genuine nonempty forecast logs verify state clearing.
Low — update the checked-in missing-LightGBM fixture (test/automl/test_holdout_labels.py:1163-1167). It monkeypatches ml.LGBMClassifier after _IMPLICIT_BINARY_CLASSIFIERS was built, so it no longer simulates absence. Prefer fresh-interpreter absence tests, including the unknown-estimator branch. No production import regression was verified.
This is only the new import/state-reset correction. It does not supply or clear any missing assignment or manual-resolution gap in the older whole-PR High review.
Independent Low review: 1/1 at the live maximum reasoning. Original findings, priorities and ISSUES_FOUND verdict are retained; these test/documentation notes are not a request to change working production behavior, and this COMMENT is not overall approval.
At 2026-12-03T11:44:17.902315+00:00, checks=FAILURE; actual current-head workflows: Build=in_progress/None; docs=completed/success; Code formatting=completed/success. Workflow permission is not CI success. No contributor source was changed and no review outputs were pushed here.
Posted by thinkall-agent-auto-reviewer
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Clean imported-base integration only, reviewed at 74e304f46ca5f10a3bccca3fe46193792ac1a5fb.
The new foreign SVC constructor change preserves explicit random_state (including None), consumes the random_seed alias, and retains clone/stacking behavior. The imported default forest classifier change leaves preprocessing to predict_proba, avoiding a second transformation while leaving regressor behavior unchanged. The selected tests pass14cases on each pinned stack (28for this head); the representative old-source controls fail26cases and pass2across stacks.
Exact merge-parent and changed-path checks show this is base alignment, not a new edit to this PR's original feature. The separate own-authored release README/docs/version paths were excluded from review. Independent Low coverage is1/1 at the live maximum reasoning, with a CLEAN verdict only for this imported-code scope. This does not resolve existing feature findings, active change requests, missing whole-PR evidence or prior safety stops, and is not overall PR approval.
All-files hooks passed for the retained local evidence commit. No contributor source was edited and no review outputs were pushed here.
At 2026-12-04T02:22:52.927435+00:00, checks=PENDING; actual current-head workflows: Build=in_progress/None; Code formatting=completed/success; docs=completed/success. Balanced Copilot approval recommendation=True; unresolved threads=0. Workflow permission is not CI success. Existing approval records, if retargeted by a base merge, are not a fresh whole-source or CI signoff.
Posted by thinkall-agent-auto-reviewer
| labels = np.arange(len(self.classes_)) if self._label_transformer else self.classes_ | ||
| proba = _align_class_probabilities(proba, estimator, labels) |
There was a problem hiding this comment.
The exported pipeline now returns one probability column per class in AutoML.classes_ order. The random forest and sparse LightGBM cases both passed an MLflow save/load round trip.
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Imported FLOW2 integration only, reviewed at d68ebf3b700875b9ba5b4883f105a4098682b194.
The imported unordered categorical choice correction picks an index instead of allowing NumPy to coerce the choice values. Tuple/mixed choices, movement and seeded draws pass14cases on each pinned stack (28for this head). Exact merge/path proofs show no new feature-author edit in this branch. Existing branch-feature findings, active change requests and missing whole-PR coverage are not cleared by this new-base review.
Independent Low coverage1/1 at maximum reasoning; original CLEAN outcome is retained. This narrow verdict is not whole-PR code-review clearance and cannot reset prior safety/coverage bounds.
All-files hooks passed for the retained local evidence commit. Own-authored workflow/package-metadata changes were excluded; no contributor source was edited and no review outputs were pushed here.
At 2026-12-04T07:22:11.970204+00:00, checks=FAILURE; actual current-head workflows: Code formatting=completed/success; Build=in_progress/None; docs=completed/success. Balanced Copilot approval recommendation=False; unresolved threads=1. Workflow permission is not CI success.
Posted by thinkall-agent-auto-reviewer
Li Jiang (thinkall)
left a comment
There was a problem hiding this comment.
Reviewed ca71ea326748e44830ed74a7eed05ee9fdb47a84 against the previously reviewed d68ebf3b700875b9ba5b4883f105a4098682b194. This pass covers only the new exported-pipeline probability axes, prediction-option bypass and successful-refit metadata correction. Six complementary Medium lenses were dispatched; only2of6 completed before the per-invocation30minute safety bound. The other four retain raw stopped receipts and were not retried. Independent coverage of this correction remains incomplete.
The 54 selected current cases pass across the two runtime stacks; predecessor controls have 34 expected failures and 20 passes. The two completed reviewers returned High/Medium/Low notes; original priorities and ISSUES_FOUND verdicts are retained with these independent qualifications.
High, qualified inherited refit bypass (pipeline.py:321-325): exported LDA fit_transform on new integer classes [1,2] keeps the old alpha/beta/gamma decoder and returns beta/gamma predictions. Configured resampling is also bypassed. Both behaviors reproduce on current, predecessor and unmodified main, on both stacks; the previously inherited sklearn method already bypassed them. The new override does not introduce that underlying defect. Consider a matching target/resampler guard or coherent refit metadata handling. No forecast-specific refit claim was dynamically verified.
Medium, qualified incomplete alignment coverage (pipeline.py:366-369): a standalone encoded AutoMLPipeline with three public labels and a sampled classifier for encoded [0,2] still returns two probability columns. This also reproduces on predecessor and main; the new first-step-only task lookup leaves that direct-construction pattern outside the fix, rather than introducing a new failure.
Low, native-axis compatibility boundary (pipeline.py:449-454): pairing a native owner for [0,1,2] with a supplied fitted classifier for [10,20] now advertises the owner's three classes_ while returning two probability columns; predecessor/main advertise [10,20]. Check class compatibility before copying _native_classes. This concerns a supplied model outside its owner's target domain, not an observed failure of the normal same-problem export.
Low polish: document exported probability-axis/raw-option/refit semantics. Dynamic native metadata already has backward-compatible getattr fallbacks; constants/fast paths are optional, not measured performance fixes. Low test hardening (test_holdout_labels.py:1218): bound the fresh import child with a timeout and preserve diagnostics. No hang or CI-failure causation was reproduced.
The six source/runtime qualification jobs have 22 successful defect/limit assertions plus two current class-domain compatibility failures; these are not additional green product tests.
This is not whole-PR approval: the older whole-feature High7/8 independent-coverage gap and existing review bounds remain held. A clean narrow correction cannot replace the missing whole-feature evidence. Same-head Balanced Copilot Approval, resolved review threads, successful check contexts and successful actual workflow runs remain separate requirements. No contributor source or tests were changed, and no review artifacts were pushed to the PR branch.
Posted by thinkall-agent-auto-reviewer
|
I reproduced the rejected refit with a reused Task. After 7ccecce the original model still returns identical probabilities. I also guarded |


Why are these changes needed?
Holdout classification can finish with infinite log loss and no model when validation data is missing a training class.
Cache the full training class set for built-in holdout metrics and align sampled models' probabilities with it. For local tabular classification, public
predict_proba()columns followclasses_, including sparse inputs, disabled preprocessing, and single-class binary and multiclass boosted samples. Non-finite backend output, diagnostic outputs and Spark outputs are preserved. Custom metric callbacks retain their existing label handling.Regression tests cover missing classes, sampled predictions, failed refits and retraining. The
predict_proba()documentation explains class ordering, missing-class columns and differences from raw model output.Related issue number
None.
Validation
Focused regression and surrounding classification tests, plus repository pre-commit hooks. Full backend and platform matrices have not been run locally.
Checks
predict_proba()class ordering and sampled-model behavior.