BWBarber
09/08/2023, 2:33 AMY_df['noise'] = np.random.rand(len(Y_df))
# split to train and test
Y_train_df = Y_df[:-horizon]
Y_test_df = Y_df[-horizon:]
# Instantiate HINT
# BaseNetwork + Distribution + Reconciliation
nhits = NHITS(h=horizon,
input_size=24,
loss=GMM(n_components=10, level=level),
hist_exog_list=['month'],
futr_exog_list=['noise'],
max_steps=2000,
early_stop_patience_steps=10,
val_check_steps=50,
scaler_type='robust',
learning_rate=1e-3,
valid_loss=sCRPS(level=level))
model = HINT(h=horizon, S=S_df.values,
model=nhits, reconciliation='BottomUp')
# Fit and Predict
nf = NeuralForecast(models=[model], freq='MS')
nf.fit(df=Y_train_df, val_size=12)
Y_hat_df = nf.predict(Y_test_df)
When I run this code, I receive the error: "RuntimeError: normal expects all elements of std >= 0.0"
Has this been seen before? Not sure exactly what's going on. Everything works fine when I comment out futr_exog_listKin Gtz. Olivares
09/08/2023, 8:20 AM# MinT along other methods require a positive definite covariance matrix
# for the residuals, when dealing with 0s as residuals the methods break
# data is augmented with minimal normal noise to avoid this error.
Y_df['y'] = Y_df['y'] + np.random.normal(loc=0.0, scale=0.01, size=len(Y_df))
BWBarber
09/08/2023, 1:58 PM