[BUG] Fix CatBoost and sparse-horizon cross-validation with Polars#613
Open
janrth wants to merge 1 commit intoNixtla:mainfrom
Open
[BUG] Fix CatBoost and sparse-horizon cross-validation with Polars#613janrth wants to merge 1 commit intoNixtla:mainfrom
janrth wants to merge 1 commit intoNixtla:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes two Polars cross-validation issues in MLForecast:
CatBoostRegressor failed on Polars inputs because the shared fit/predict path passed polars.DataFrame objects directly into CatBoost, which only accepts pandas/numpy-style inputs.
Sparse-horizon cross-validation (horizons=[...]) failed on Polars because the expected-row validation used pandas-only .nunique() on a Polars series.
Changes to fix this:
In the shared model fit path, CatBoost inputs are converted from Polars to pandas before calling .fit(...).
In the shared prediction path, CatBoost inputs are likewise converted from Polars to pandas before calling .predict(...).
In sparse-horizon cross-validation, the expected series count now uses:
.nunique() for pandas
.n_unique() for Polars
Added targeted regression tests covering:
Polars cross-validation with a CatBoost-like estimator on the shared fit/predict path
Polars sparse-horizon cross-validation with refit=False
Solves #594
Checklist: