Zero and Negative Y data

(Hiddendeveloper) #1

I am looking at something similar to Rossmann sales forecast but my dataset includes returns and therefore I have negative sales and zero sales.

When I use the exp_rmspe calculation I get nan and infinity errors. Is there anyway I can overcome this?

Thanks for your help and patience.

(Theodoros Galanos) #2

Did you try scaling?

(Hiddendeveloper) #3

Thanks for your help. i tried taking the minimum amount of the dataset and then added the absolute of it plus 1 to all of the amounts. eg.

MIN_AMT = XX[‘AMT’].min()
XX[‘AMT’] = XX[‘AMT’] + (abs(MIN_AMT) + 1)

This seems to do the trick and I am no longer getting errors and have a good exp_rmspe

(Hiddendeveloper) #4

Can someone help?

Although the training loss, validation loss and exp_rmspe is great < 1 the prediction results after trying to rescale are awful.

For example The prediction gives me x and y of x=999360.5 Y=1051301 a x/y of 0.94
but when I rescale. eg

(abs(MIN_SALES) + 1) = 1032401

x = x - (abs(MAX_SALES)+1) and y = y - (abs(MAX_SALES)+1)
The x, y results become x= -33040.5 and y=18900.
The y is the correct sales but the x predictions is nowhere close

I tried pre normalizing the Sales data and then denormalizing the predictions but similar awful results.
Note that initially it would even run the learning rate but when I used y_range=None it got seemingly fantastic results of 0.03.
np.exp(x) and np.exp(y) are 0.28602 and 0.27884 and looks closebut after denomarlized
denormalize(np.exp(x[0]),-1032400, 2737800) = 45957.13881 which is an awful prediction
denormalize(np.exp(y[0]),-1032400, 2737800) = 18900.00426 which is the correct sales

my normalize and denormalize functions are below.

Any suggestions? Unfortunately my Math is quite weak.

def normalize(value, min, max):
normalized = (value - min) / (max - min);
return normalized;

def denormalize(normalized, min, max):
denormalized = (normalized * (max - min) + min);
return denormalized;