Add forecasting models and metrics - #852
Merged
Merged
Conversation
cristian-tamblay
force-pushed
the
feat/forecasting-models
branch
from
August 31, 2026 22:27
3ca88da to
c9796e0
Compare
cristian-tamblay
force-pushed
the
feat/forecasting-models
branch
from
September 1, 2026 12:58
c9796e0 to
c8a5b62
Compare
cristian-tamblay
force-pushed
the
feat/forecasting-models
branch
from
September 1, 2026 14:00
c8a5b62 to
13fbb0f
Compare
Four models for ForecastingTask, all reading the series out of the target and treating predict's argument as a request for a length rather than as features to score. NaiveForecaster and SeasonalNaiveForecaster need no dependency and exist to be beaten: a model that cannot beat them has found nothing in the data, and DashAI previously gave no way to check that. ARIMA and ExponentialSmoothing wrap statsmodels, which was already a dependency. RegressionMetric now lists ForecastingTask as well, which makes MAE, MSE, RMSE, R2 and the rest available to forecasting runs without reimplementing any of them. MAPE and sMAPE are added on top, both as RegressionMetric subclasses so they also serve the windowed route through RegressionTask. MAPE skips rows whose true value is zero rather than dividing by them, and reports nan for an all-zero series. sMAPE exists because that limitation is real, and it is the one to reach for on series that touch zero.
cristian-tamblay
force-pushed
the
feat/forecasting-models
branch
from
September 1, 2026 14:18
13fbb0f to
6322ba0
Compare
cristian-tamblay
approved these changes
Sep 1, 2026
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.
Summary
Adds the models and metrics that make
ForecastingTaskusable. Last of the four branches implementing forecasting.Four models, all sharing an unusual contract for DashAI: they learn no mapping from features to a target, because there are no features. The only input is a date column, and everything the model knows comes from the history of the series itself. So
trainreads the series out ofy_trainand ignores the feature matrix, andpredicttreats its argument as a request for a length rather than as data to score, returning one value per row continuing from where training ended.That is exactly why the windowed route through
TimeSeriesWindowConverterandRegressionTaskexists alongside this one: it turns history into real features, which is the only way an ordinary regressor can help.Type of Change
Check all that apply like this [x]:
Changes (by file)
DashAI/back/models/forecasting/base_forecasting_model.py: new.ForecastingModel(BaseModel)withCOMPATIBLE_COMPONENTS = ["ForecastingTask"], the shared series reader, the horizon reader, joblib save and load, and a guard that refuses to forecast before training.DashAI/back/models/forecasting/naive.py: predicts that the series stays where it last was. No dependency, nothing to tune.DashAI/back/models/forecasting/seasonal_naive.py: predicts that each season repeats the one before.season_length = 1makes it the plain naive forecast.DashAI/back/models/forecasting/arima.py: wrapsstatsmodels.tsa.arima.model.ARIMA, exposingp,dandqas optimizable orders.DashAI/back/models/forecasting/exponential_smoothing.py: wraps statsmodels Holt Winters, exposingtrend,seasonalandseason_length.DashAI/back/metrics/regression_metric.py: addForecastingTasktoCOMPATIBLE_COMPONENTS. One line, and it is what makes MAE, MSE, RMSE, R2, median absolute error and explained variance available to forecasting without reimplementing any of them.DashAI/back/metrics/forecasting/mape.py,smape.py: new percentage error metrics.DashAI/back/initial_components.py: register the four models and two metrics.tests/back/models/test_forecasting_models.py,tests/back/metrics/test_forecasting_metrics.py: new. 24 and 11 tests.Testing (optional)
Notes (optional)
One deviation from the spec, which had MAPE and sMAPE as forecasting only metrics. They subclass
RegressionMetricinstead, so they serve both routes to a forecast. Restricting them to the native task would have left a user on the windowed route unable to use the metrics most natural for the thing they are doing.MAPE divides by the true value, so it is undefined wherever that value is zero. Those rows are skipped rather than allowed to produce an infinity that would swallow the score, and an all zero series reports
nan. sMAPE exists precisely because that limitation is real: it divides by the average of both values, stays defined at zero, caps at 200 percent, and does not punish over forecasting more than under forecasting.Both statsmodels wrappers suppress the warning about assuming evenly spaced observations. That assumption is deliberate here, so the warning says nothing the model does not already document.
Seasonal ARIMA is not exposed: it would need three more orders, and
ExponentialSmoothingwith a seasonal component covers seasonality more legibly. Prophet remains out of scope for now, being a heavy dependency and the model most likely to need the exogenous variables that are a separate task.