Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

Multi-Target Support Implementation - Complete ✅

All requirements from the issue have been successfully implemented and tested.

Implementation Summary

  • Accept 2D target arrays: Modified validation logic to accept (n_samples, n_targets) arrays
  • Automatic estimator filtering: Only XGBoost and CatBoost are allowed for multi-target
  • CatBoost configuration: Automatically uses MultiRMSE objective for multi-target
  • Correct data splitting: Fixed CV and holdout splitting for 2D targets
  • Metric computation: Uses sklearn's built-in averaging for multi-target metrics
  • Prediction shape preservation: Returns (n_samples, n_targets) predictions
  • DataFrame support: Works with pandas DataFrames for both X and y
  • Comprehensive tests: 8 tests covering all scenarios (100% pass rate)
  • Backward compatibility: Existing single-target tests still pass
  • Code formatting: All files formatted with pre-commit hooks

Files Changed

  1. flaml/automl/automl.py

    • Updated fit() docstring to document multi-target support
    • Modified predict() to preserve multi-target shape
    • Added multi-target flag passing to estimator selection
  2. flaml/automl/task/generic_task.py

    • Modified validate_data() to accept 2D y arrays/DataFrames
    • Added multi-target detection logic
    • Updated default_estimator_list() to filter unsupported estimators
    • Fixed CV splitting for DataFrame targets
  3. flaml/automl/task/task.py

    • Updated abstract method signature for default_estimator_list()
  4. flaml/automl/task/time_series_task.py

    • Updated method signature to match abstract class
  5. flaml/automl/model.py

    • Added multi-target detection in CatBoostEstimator.fit()
    • Automatic MultiRMSE objective selection
  6. flaml/automl/data.py

    • Skip label encoding for multi-target regression DataFrames
  7. test/automl/test_multi_target.py (NEW)

    • 8 comprehensive tests for multi-target functionality
  8. examples/multi_target_regression_demo.py (NEW)

    • Complete demo showing all features

Usage Example

from sklearn.datasets import make_regression
from flaml import AutoML

# Create multi-target data
X, y = make_regression(n_samples=100, n_features=10, n_targets=3)

# Train AutoML (automatically selects XGBoost or CatBoost)
automl = AutoML()
automl.fit(X, y, task='regression', time_budget=30)

# Predict - returns (n_samples, 3) array
predictions = automl.predict(X_test)

Testing Results

  • ✅ All 8 new multi-target tests pass
  • ✅ Existing regression tests pass (backward compatibility confirmed)
  • ✅ Demo script runs successfully
  • ✅ Pre-commit formatting checks pass
Original prompt

This section details on the original issue you should resolve

<issue_title>Add (built-in) multi-target support </issue_title>
<issue_description>Hi!

Thank you for providing this useful AutoML package.

In several of the main tree models (e.g. XGBoost 2.0, CatBoost) the regressors support fitting against multiple targets (see here and here). With recent advances with multi_output_tree, these multi-output regression/classification models tend to be pretty useful.

Would it be possible to modify the AutoML class to support passing a 2-d "y" targets array-like input to .fit() for regression tasks ?

I think the implementation would require:

  • modifying asserts / code checks to accept a 2-d multi-targets
  • if multi-output input is detected: assert that the model list is supported (e.g. XGBoost & CatBoost work, whereas LightGBM does not yet have built-in support for it outside of wrapping with sklearn MultiOutput Regressor). Then modify default parameters to accomodate multi-target as needed, e.g. for CatBoost regression the default objective needs to be "MultiRMSE" instead of "RMSE". These are minor changes to default parametrization, if any.
  • ensure splitters split y, if 2D, correctly and pass as-is to the underlying model(s)
  • for cross-validate scores: define a default policy of e.g. averaging scores per target to be used as final tuning validation score

Doing this abstracts away implementation details of single vs multi-output for users and allows FLAML to "just work" for either

Thanks for considering,
Azmy
</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 10, 2026 08:44
- Modified validation to accept 2D y arrays (n_samples, n_targets)
- Added multi-target detection in generic_task.validate_data
- Filtered unsupported estimators (only XGBoost, CatBoost support multi-target)
- Configured CatBoost with MultiRMSE objective for multi-target
- Fixed AutoML.predict to not flatten multi-target predictions
- Updated AutoML.fit docstring to document multi-target support

Co-authored-by: thinkall <3197038+thinkall@users.noreply.github.com>
- Skip label encoding for multi-target regression DataFrames
- Fix CV splitting to use iloc for DataFrame y-values
- Add comprehensive multi-target regression tests

Co-authored-by: thinkall <3197038+thinkall@users.noreply.github.com>
- Added comprehensive demo showing all features of multi-target support
- Demonstrates XGBoost and CatBoost support
- Shows estimator filtering
- Includes DataFrame support examples

Co-authored-by: thinkall <3197038+thinkall@users.noreply.github.com>
Copilot AI changed the title [WIP] Add multi-target support to AutoML class Add native multi-target regression support Jan 10, 2026
Copilot AI requested a review from thinkall January 10, 2026 08:53
@thinkall thinkall marked this pull request as ready for review January 20, 2026 14:56
@thinkall
Copy link
Collaborator

@copilot , run pre-commit run --all-files to fix formatting.

- Changed single quotes to double quotes for consistency
- Removed trailing whitespace
- Fixed line spacing

Co-authored-by: thinkall <3197038+thinkall@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 21, 2026

@copilot , run pre-commit run --all-files to fix formatting.

Fixed formatting issues in commit 0990d8f. All pre-commit checks now pass.

@thinkall thinkall marked this pull request as draft January 21, 2026 07:07
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.

Add (built-in) multi-target support

2 participants