Comments (3)
In my opinion those APIs are more restrictive, since historic means "use a specific lag of these features" (output_chunk_length
in darts and h
in neuralforecast).
If you want to turn a feature into historic in mlforecast you can just use a lag that is longer than your forecasting horizon, for example:
import pandas as pd
from mlforecast import MLForecast
from mlforecast.utils import generate_series, generate_prices_for_series
from sklearn.linear_model import LinearRegression
# generate data. the prices span the full range of training dates (so it's a future exog)
series = generate_series(2, equal_ends=True)
prices = generate_prices_for_series(series, horizon=0)
# turn to historic
prices_lag5 = prices.rename(columns={'price': 'price_lag5'})
prices_lag5['ds'] += 5 * pd.offsets.Day()
prices_lag10 = prices.rename(columns={'price': 'price_lag10'})
prices_lag10['ds'] += 10 * pd.offsets.Day()
historic_prices = prices_lag5.merge(prices_lag10, on=['unique_id', 'ds'])
# merge with training set. this drops some rows but if you have more history you wouldn't need to
train = series.merge(historic_prices, on=['unique_id', 'ds'])
# use the regular API for training and forecasting
mlf = MLForecast(
models=[LinearRegression()],
freq='D',
)
mlf.fit(train, static_features=[])
mlf.predict(h=5, X_df=historic_prices)
Since h=5
here we can use any lag>=5 as "historic" (5 and 10 in this example).
This doesn't seem that hard. It would be harder to add a new argument to determine which lag to take, a new argument to provide the historic features, etc.
from mlforecast.
Thanks @jmoralez! I will close this as the procedure seems simple enough. We may reopen later if needed.
from mlforecast.
I have the same question. Can I construct the features before training and hence I can incorporate those features into feature engineering process.
from mlforecast.
Related Issues (20)
- Mlforecast + AutoDifferences + fitted=True HOT 2
- get performance on training set HOT 2
- Unbale to do LogTransformation using target_transformation HOT 2
- [MLForecast] Add the possibility to pass custom parameters to the fit function HOT 6
- Forecasting produces nearly horizontal results HOT 4
- Cross validation with prediction_intervals and in-sample predictions enabled lacks folds
- MLForecast LinearRegression Isn't Applied to Each Unique Id Time Series Seperately HOT 1
- Not enough models trained in cross_validation with fitted=True and horizon > 9
- [Custom Training] Add custom training for Cross Validation
- Found missing inputs in X_df. It should have one row per id and time for the complete forecasting horizon. HOT 13
- [core] speed up date features calculation
- Electricity load tutorial problem HOT 3
- SHAP with exogenous features HOT 4
- All series are too short for the cross validation settings
- ValueError on make_future_dataframe HOT 3
- Multi-Step Training Predictions
- Unable to make forecasts on new data HOT 4
- LightGBM + GroupedArray._tail() + num_threads>1 HOT 3
- Custom prediction intervals
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mlforecast.