Prepare the data
Build input windows and next-step targets without letting windows cross validation boundaries.
Learn from a window. Predict beyond its end.
An LSTM processes a sequence with gated recurrent state. Correct window construction, chronological splits and simple forecasting baselines matter more than network size.
Learning concept · Not a validated service
An LSTM processes a sequence with gated recurrent state. Correct window construction, chronological splits and simple forecasting baselines matter more than network size.
A possible application for time-series classes: Help time-series students compare learned sequence state with explicit lag features. This extension is not delivered by the supplied starter.
Build input windows and next-step targets without letting windows cross validation boundaries.
Train a small LSTM on scaled training sequences with early stopping.
Compare chronological MAE with persistence and lag-feature regression across several seeds.
Show windowed inputs, next-step predictions and the limits of the tested horizon.
The supplied starter generates 240 daily values with trend, seasonality and noise. It builds lagged and shifted rolling features, trains a RandomForestRegressor on earlier rows and reports MAE on the final thirty rows.
for lag in [1, 7, 14]:
series[f"lag_{lag}"] = series["value"].shift(lag)
series["rolling_7"] = series["value"].shift(1).rolling(7).mean()
series = series.dropna()
train = series.iloc[:-30]
test = series.iloc[-30:]
model = RandomForestRegressor(n_estimators=300, random_state=42)
model.fit(train[feature_cols], train["value"])
forecast = model.predict(test[feature_cols])The source fits a random forest on lag columns, not an LSTM network. Later test rows use actual earlier test values as lag inputs. This can represent rolling one-step prediction, but not a thirty-day forecast made at a single origin. There are no prediction intervals or real operational observations.
Proposed extension: Help time-series students compare learned sequence state with explicit lag features.
This is a potential application pathway, not a delivered product. The supplied starter does not implement this service or validate it with real users.
Networkers Home runs this topic inside its AI Engineer Course, with placement support and hands-on labs.