Skip to main content


Perform nhits forecast:


nhits [--num-stacks NUM_STACKS] [--num-blocks NUM_BLOCKS] [--num-layers NUM_LAYERS] [--layer_widths LAYER_WIDTHS] [--activation {ReLU,RReLU,PReLU,Softplus,Tanh,SELU,LeakyReLU,Sigmoid}] [--max_pool_1d] [--past-covariates PAST_COVARIATES] [--all-past-covariates] [--naive] [-d {}] [-c TARGET_COLUMN] [-n N_DAYS] [-t TRAIN_SPLIT] [-i INPUT_CHUNK_LENGTH] [-o OUTPUT_CHUNK_LENGTH] [--force-reset FORCE_RESET] [--save-checkpoints SAVE_CHECKPOINTS] [--model-save-name MODEL_SAVE_NAME] [--n-epochs N_EPOCHS] [--dropout DROPOUT] [--batch-size BATCH_SIZE] [--end S_END_DATE] [--start S_START_DATE] [--residuals] [--forecast-only] [--export-pred-raw]


num_stacksThe number of stacks that make up the model3TrueNone
num_blocksThe number of blocks making up every stack1TrueNone
num_layersThe number of fully connected layers2TrueNone
layer_widthsThe number of neurons in each layer512TrueNone
activationThe desired activationReLUTrueReLU, RReLU, PReLU, Softplus, Tanh, SELU, LeakyReLU, Sigmoid
maxpool1dWhether to use max_pool_1d or AvgPool1dTrueTrueNone
past_covariatesPast covariates(columns/features) in same dataset. Comma separated.NoneTrueNone
all_past_covariatesAdds all rows as past covariates except for date and the target column.FalseTrueNone
naiveShow the naive baseline for a model.FalseTrueNone
target_datasetThe name of the dataset you want to selectNoneTrueNone
target_columnThe name of the specific column you want to usecloseTrueNone
n_daysprediction days.5TrueNone
train_splitStart point for rolling training and forecast window. 0.0-1.00.85TrueNone
input_chunk_lengthNumber of past time steps for forecasting module at prediction time.14TrueNone
output_chunk_lengthThe length of the forecast of the model.5TrueNone
force_resetIf set to True, any previously-existing model with the same name will be reset (all checkpoints will be discarded).TrueTrueNone
save_checkpointsWhether to automatically save the untrained model and checkpoints.TrueTrueNone
model_save_nameName of the model to save.nhits_modelTrueNone
n_epochsNumber of epochs over which to train the model.300TrueNone
dropoutFraction of neurons affected by Dropout, from 0 to 1.0.1TrueNone
batch_sizeNumber of time series (input and output) used in each training pass32TrueNone
s_end_dateThe end date (format YYYY-MM-DD) to select for testingNoneTrueNone
s_start_dateThe start date (format YYYY-MM-DD) to select for testingNoneTrueNone
residualsShow the residuals for the model.FalseTrueNone
forecast_onlyDo not plot the historical data without forecasts.FalseTrueNone
export_pred_rawExport predictions to a csv file.FalseTrueNone


2022 Oct 11, 06:38 D /forecast/ $ load AAPL_20220719_201127.csv

2022 Oct 11, 06:38 D /forecast/ $ nhits AAPL_20220719_201127
Epoch 153: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 25/25 [00:0000:00, 183.87it/s, loss=-1.56, train_loss=-1.60, val_loss=-.954]
Predicting NHITS for 5 days
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 115/115 [00:0100:00, 92.46it/s]
NHITS model obtains MAPE: 7.45%

Actual price: 147.07
┃ Datetime ┃ Prediction ┃