Skip to content

Commit 3953cb9

Browse files
committed
fix: update output schema for regression task predictions to ensure correct data type
1 parent 6936100 commit 3953cb9

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

DashAI/back/job/predict_job.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from DashAI.back.job.base_job import BaseJob, JobError
1313
from DashAI.back.models.base_model import BaseModel
1414
from DashAI.back.tasks.base_task import BaseTask
15+
from DashAI.back.tasks.regression_task import RegressionTask
1516

1617
if TYPE_CHECKING:
1718
from sqlalchemy.orm import sessionmaker
@@ -482,6 +483,14 @@ def run(
482483
if key in model_session.input_columns + model_session.output_columns
483484
}
484485

486+
# Regression models predict continuous values regardless of
487+
# the training target's original dtype (e.g. a target column
488+
# that happened to hold only integer-looking values), so the
489+
# output column's saved schema must reflect that instead of
490+
# inheriting the training dataset's type.
491+
if isinstance(task, RegressionTask):
492+
filtered_schema[output_col] = {"type": "Float", "dtype": "float64"}
493+
485494
# Store num of rows, columns, and column names
486495
dataset_with_prediction.compute_base_metadata()
487496

0 commit comments

Comments
 (0)