Skip to content

Fix CatBoost and XGBoost evals_result handling - #2327

Open
mrlonely (mameikagou) wants to merge 1 commit into
microsoft:mainfrom
mameikagou:agent/fix-model-evals-result
Open

Fix CatBoost and XGBoost evals_result handling#2327
mrlonely (mameikagou) wants to merge 1 commit into
microsoft:mainfrom
mameikagou:agent/fix-model-evals-result

Conversation

@mameikagou

Copy link
Copy Markdown

Description

Fix evaluation-result handling in the CatBoost and XGBoost model wrappers.

  • CatBoostModel.fit now preserves and updates a caller-provided evals_result dictionary instead of rebinding the local variable and silently discarding the output.
  • Both wrappers now use None instead of a mutable dictionary as the default argument.
  • Add focused, network-free regression tests for caller mutation and fresh defaults.

Root cause

CatBoostModel.fit assigned self.model.get_evals_result() to the local evals_result name. When a caller passed a dictionary, that dictionary was never populated. Both wrappers also declared evals_result=dict() in the function signature, sharing one dictionary across calls that omit the argument.

Impact

Callers can reliably collect train and validation metric histories through the same evals_result contract used by the other Qlib model wrappers. Existing calls that omit the argument remain compatible.

Validation

  • Regression check against the previous implementation: 4 failures / 1 pass
  • Patched focused tests: 5 passed
  • Black (--target-version py38 --line-length 120): passed
  • Flake8 with the repository ignore set: passed

Risk

Low. The model training calls and returned model objects are unchanged; the patch only corrects the optional output dictionary and removes mutable defaults.

@mameikagou

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@mameikagou
mrlonely (mameikagou) marked this pull request as ready for review August 19, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant