Home > Net >  "Found array with dim 3. Estimator expected <= 2" Error when using scaler.inverse_trans
"Found array with dim 3. Estimator expected <= 2" Error when using scaler.inverse_trans

Time:10-18

I am building a Neural Network, I do a transformation to all the data sample before the split to test and train samples:

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

After splitting I check the dimensions of the target_test and target_train samples:

Target_train.ndim
Target_test.ndim

The dimensions are equal to 2. When I try to inverse the transformation:

Target_train = scaler.inverse_transform([Target_train])
Target_test = scaler.inverse_transform([Target_test])

I get the following error: Found array with dim 3. Estimator expected <= 2.

I am confused to why I am having this error since the dimensions are equal to 2. Any ideas on what could be the problem?

CodePudding user response:

You are passing a singleton [Target_train] which has one more dimension, it is 1 x [samples x features], just pass Target_train alone.

  • Related