Sequences, streaming data, robotics, and scientific extensions · Entry index · SEQ016 · Model
N-HiTS: Neural Hierarchical Interpolation for Time Series Forecasting
A forecasting architecture combining multi-rate input sampling and hierarchical interpolation of forecast coefficients.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page.
- N-HiTS neural forecast Verified in Python and R
Do it in CodeSplash Run it on your own data, in Python or R.
- Availability
- Runs in CodeSplash
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's own run
- CodeSplash's run
- Verified in Python and R through forecast.nhits. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review, but on a different version of the code. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
A forecasting architecture combining multi-rate input sampling and hierarchical interpolation of forecast coefficients. Residual blocks decompose history and add forecasts at different temporal resolutions, reducing the cost of long-horizon prediction. It is a distinct multiscale design within the residual neural-forecasting lineage, rather than a generic smoothing procedure.
Question / hypotheses
Can coarse-to-fine residual forecasting represent long-horizon patterns efficiently without losing important temporal detail? There is no significance-test null. Evaluate horizon-wise forecast error, compute, and sensitivity to temporal resolution against comparable baselines.
Architecture / computational structure
Each block receives pooled residual input, produces a backcast subtraction and an interpolated forecast contribution, and passes the remaining residual onward. Different stacks operate at different resolutions. The hierarchy joins representation at input scales with structured expansion at forecast scales.
Assumptions
Historical windows and any covariates must obey forecast-time availability. Pooling and interpolation assume useful predictability exists at their chosen resolutions; sharp events and irregular sampling may require special handling. Repeated windows from one series are dependent and should not be randomly split as independent examples.
Formula / computational definition
At block , pool residual history , map it to backcast/forecast coefficients, and compute . The final forecast is . Coarse coefficient grids and interpolation generate full-horizon contributions without independently predicting every future value in each block.
Parameters and notation
Learned parameters: block multilayer-perceptron weights and backcast/forecast coefficient heads. Hyperparameters: context/horizon, stack/block counts, pooling rates, coefficient resolutions, interpolation mode, hidden widths, and forecast loss. Coarser grids lower cost but constrain rapidly changing forecast shapes.
Fitting, fine-tuning, and adaptation
Fit rolling windows with chronological validation and an appropriate error loss. For a related domain, fine-tune coefficient heads first or adapt complete blocks at a smaller learning rate, comparing with fitting from scratch. Reconsider resolutions when sampling rate or horizon changes; unchanged weights do not preserve the original scale interpretation.
How to use and calibrate
Report errors by horizon and frequency regime, training/inference cost, and simple seasonal benchmarks. Inspect block contributions without treating them as uniquely identified causal components. Check whether interpolation oversmooths peaks and whether errors are dominated by a few high-scale series.
Example application
Build a synthetic trend-plus-seasonal series and visualize coarse and finer interpolated forecast contributions over a long horizon before training a full model.
Interpretation / pitfalls
Watch out
Python: paper-associated implementations or documented N-HiTS libraries; R: reticulate with native interpolation/forecast analysis. The paired example computes one fixed interpolation contribution only; no pooling network, learned coefficients, residual fitting, or forecast evaluation is performed.
Python and R code examples (dependencies/validation)
Python uses NumPy and the shared mse helper when called; base R uses the shared helper when called. Validation: Python component executed; R companion reviewed, not executed. Scope: the specific component described above, not the full model or its training.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — synthetic mathematical component, not a full-model implementation
Shared setup for this chapter
import numpy as np
def mse(a,b):
a,b=np.asarray(a),np.asarray(b)
if a.shape!=b.shape or a.size==0:
raise ValueError("MSE needs nonempty equal shapes")
return float(np.mean((a-b)**2))
knots=np.array([0.,2.5,5.]); coefficients=np.array([1.,1.6,1.2]); horizon=np.arange(6.)
forecast=np.interp(horizon,knots,coefficients)
result={"forecast_contribution":forecast.tolist(),"endpoint_check":bool(np.isclose(forecast[-1],1.2))}
print(result)
Component demo, not a trained model — synthetic mathematical component, not a full-model implementation
Shared setup for this chapter
mse <- function(a,b) {
stopifnot(length(a)>0L, identical(dim(a),dim(b)), length(a)==length(b))
mean((a-b)^2)
}
knots <- c(0,2.5,5); coefficients <- c(1,1.6,1.2); horizon <- 0:5
forecast <- approx(knots,coefficients,xout=horizon,rule=2)$y
result <- list(forecast_contribution=forecast,endpoint_check=isTRUE(all.equal(tail(forecast,1),1.2)))
print(result)
Sources
- Source 1arxiv.org
- Source 2ojs.aaai.org
From the CodeSplash reference, entry SEQ016.