Skip to content

Fix regression prediction crashes - #855

Merged
cristian-tamblay merged 2 commits into
developfrom
fix/regression-prediction-crashes
Sep 1, 2026
Merged

Fix regression prediction crashes#855
cristian-tamblay merged 2 commits into
developfrom
fix/regression-prediction-crashes

Conversation

@Creylay

@Creylay Creylay commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Predicting with a trained regression model crashed in two different, unrelated ways depending on which estimator was used. First, saving the results always inherited the target column's original type from the training dataset, so if that column happened to be integer-valued, PyArrow refused to cast a genuinely fractional prediction (e.g. 6.87) into int64. Second, some estimators (e.g. LinearRegression) returned 2D (n, 1) predictions instead of 1D (n,) because the training target was fed to .fit() as a single-column DataFrame instead of a flat array. Tree/ensemble estimators like AdaBoostRegressor silently flattened this internally, but linear estimators preserved the 2D shape, and the dataset-saving step only accepts 1D arrays.


Type of Change

Check all that apply like this [x]:

  • Backend change
  • Frontend change
  • CI / Workflow change
  • Build / Packaging change
  • Bug fix
  • Documentation

Changes (by file)

  • DashAI/back/job/predict_job.py: when saving prediction results, force the output column's schema to Float for RegressionTask instead of inheriting the training dataset's original (possibly Integer) column type, so fractional predictions no longer fail PyArrow's cast.
  • DashAI/back/models/scikit_learn/sklearn_like_model.py: squeeze the training target to a 1-D Series before calling .fit(), so every scikit-learn estimator (not just the ones that flatten it internally) trains and predicts with a consistent 1-D shape.

Testing

  • Reproduced both crashes before the fix (integer-schema cast failure with a fractional prediction, and 2D-shape failure with LinearRegression) and confirmed both are resolved after.
  • Ran tests/back/models/test_tabular_class_models.py, tests/back/api/test_predict_api.py, and tests/back/api/test_model_session_api.py. All pass, confirming classification models (which share the same base class) are unaffected.

@cristian-tamblay
cristian-tamblay merged commit 1501053 into develop Sep 1, 2026
21 checks passed
@cristian-tamblay
cristian-tamblay deleted the fix/regression-prediction-crashes branch September 1, 2026 18:35
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.

2 participants