[ANN] MachineLearningForecast.jl: forecasting with any MLJ regressor

MachineLearningForecast.jl: Forecasting with any MLJ regressor

I’m happy to share MachineLearningForecast.jl, a package for time-series forecasting that turns any MLJ Deterministic regressor into a forecaster. EvoTrees, XGBoost, LightGBM, random forests, linear models: nothing is hard-coded, so you bring the learner and the package handles the lag features, the recursion, and the backtesting.

Two things it tries to get right. Features built from the target’s history can only see rows strictly before the target, so leakage is structurally ruled out rather than left to you to check. And setting id= fits one global model across a whole panel of series, so short series borrow strength from the rest.

using MachineLearningForecast, EvoTrees, Dates

fc = Forecaster(
    EvoTreeRegressor(nrounds=200, eta=0.05);
    features = FeatureSet(
        Lag(1), Lag(7),
        RollingMean(7; lag=1),
        Calendar(:dayofweek, :month),
        Fourier(365.25, 3),
        Exogenous(:promo),          # known into the future
    ),
    strategy = Recursive(),          # or Direct(28)
    freq = Day(1), target = :y, time = :ds,
)

fcast = forecast(fit(fc, df), 28; new_data = future_exog)

backtest(fc, df; horizon=28, initial=730, step=28, metrics=(mae, rmse, smape))

Input is anything Tables.jl accepts, and the package itself depends only on Tables.jl. There’s also a tune function that searches over models, feature sets and strategies, scoring candidates by backtest error instead of one-step tabular error.

A warning up front: this is early-stage. It is tested and usable, but young, the API is not stable, and breaking changes are likely. Try it and tell me what breaks, rather than pinning production work to it. Feedback on the API is especially welcome while changing it is still cheap.

Repo: GitHub - Akai01/MachineLearningForecast.jl · GitHub

As always, phenomenal package, thanks for the effort that clearly went into this release!

Nice to see this integration with MLJ, thank you. This looks like a huge, well-thought out effort.

A warning for using EvoTrees.jl with MLJ: A long standing bug meant tuning an EvoTrees.jl learner using MLJ’s TunedModel wrapper was broken. This is fixed but you must use EvoTrees.jl v0.18.8 or higher to get the fix.

What’s the reason for having the home-grown metrics? StatisticalMeasures.jl aims to be pretty comprehensive. There is the multimeasure wrapper to handle multi-targets, which I expect you want for forecasting. I can support PR’s to add whatever’s missing.

Thank you for creating and maintaining MLJ, I like the interfaces they are very intuitive. Contributions and suggestions are welcomed.