Hi folks, my neural forecast model is outputting s...
# neural-forecast
s
Hi folks, my neural forecast model is outputting some negative values for Y_fitted, but the target should always be non-negative. Thinking of fixing it with a ReLU/Softplus output or a log transformation or else max(value, 0). So, that I can evaluate the metrics and later I can use it in the Y_rec (reconciliation). Anyone dealt with this before or what is the best approach to do so. I'd be grateful if anyone could assist me. Thanks in advance.
j
you could try a minmaxscaler set to 0,1
j
But did it generally create a good fit? It looks a bit like bad learning. Of course you can fix it with a scaler or just force values smaller 0 to 0. but if learning g is bad generally, I would go back and create a better model in the first place. And in most cases of learning works well, then the small amount of negative values can be put to 0 for example.
j
if we scale to (0,1) it should only learn to output distributions in (0,1). The default activation for NHITS is ReLU. You can always give it a try and see what happens.
s
Thank you, @Jonathan Mackenzie & @jan rathfelder. I will check with MinMaxScaler, as the fit was not satisfactory, with 21% negative values. The MAE results for both NHITS and NBEATS are 46.0280 and 45.1713, respectively. This discrepancy is due to noisy data."
m
You could also try using a non-negative loss, like Poisson. However, something is definitely weird with the dataframe you share, because NBEATS and NHITS shouldn't be that far off from the target (predicting 0 when the actual is 45). Without more info, this looks very strange.
s
Thanks @Marco I'll investigate further to understand the issue with the dataframe and ensure the models are aligned correctly. Down here this are the results using statsforecast & mlforecast. And those results are not that far off from the target. I also noticed that these negative results appear primarily in the early stage.
j
Looks mich better. Cool :)