0

I have normalized my data using the following:

scaler = StandardScaler()
train = scaler.fit_transform(train)
test = scaler.transform(test)

I later split my train and test sets into my X and y's:

X_train, y_train = train[:,1:21], train[:, np.shape(train)[1] - 2:]
X_test, y_test = test[:,1:21], test[:, np.shape(test)[1] - 2:]

I then pass these into a complex ML code.

I want to be able to easily revert my y_test and my y_pred that gets spit out by this code into their un-normalized scale (for plotting purposes).

I know that y_test = scaler.inverse_transform(y_test) could be used if transform() had been applied to y_test rather than train.

Is there a solution to this that I am overlooking?

Andrea
  • 607
  • 8
  • 21
  • 1
    The way I see it, you are better having two separate scalers, on for features, one for target. Otherwise, you can either concatenate `X_test, y_pred` and use that transform or rescale by manually by accessing `scaler.scale_` and `scaler.mean_`. – Quang Hoang Oct 09 '20 at 15:27
  • @QuangHoang, thank you for your comment. I will apply two separate scalers. That may be just the simplest answer to this. – Andrea Oct 09 '20 at 15:56

0 Answers0