# Should we denormalize our data after normalization?

If we use sklearn library's preprocessing.normalize() function to normalize our data before learning, like this:

preprocessing.normalize(training_set)


Should we do a denormalization to the result of LSTM to get predicted result in a true scale? If yes, how to denormalize?

The implication in your question is that you're normalising the target variable as well as the predictors. In general, I think that's probably not the right thing to be doing, and that you should be excluding the target from normalisation. That being the case, no inverse transformation after training should be necessary.

This can be done in Python using scaler.inverse_transform.

Consider a dataset that has been normalized with MinMaxScaler as follows:

# normalize dataset with MinMaxScaler
scaler = MinMaxScaler(feature_range=(0, 1))
dataset = scaler.fit_transform(dataset)

# Training and Test data partition
train_size = int(len(dataset) * 0.8)
test_size = len(dataset) - train_size
train, test = dataset[0:train_size,:], dataset[train_size:len(dataset),:]

# reshape into X=t-50 and Y=t
previous = 50
X_train, Y_train = create_dataset(train, previous)
X_test, Y_test = create_dataset(test, previous)

# reshape input to be [samples, time steps, features]
X_train = np.reshape(X_train, (X_train.shape, 1, X_train.shape))
X_test = np.reshape(X_test, (X_test.shape, 1, X_test.shape))


Upon generating the predictions from LSTM, the same can be converted back using scaler.inverse_transform as follows:

model = Sequential()

• May I ask, how would we inverse normalise the "out-of-time" forecast? For the completely new time-tick forecast $t+1$ we can't use the min/max, computed up to the $t$ tick - correct? – Alexander Shubert Mar 11 at 21:48