Home > Software design >  ValueError: X has 1 features, but MinMaxScaler is expecting 4 features as input
ValueError: X has 1 features, but MinMaxScaler is expecting 4 features as input

Time:12-27

I receive this error every time then I want to make

scaler.transform(model_inputs)

Here is my data

 
df = pd.DataFrame({'y': close, 'h':close_high_o,'o':open_arr_o,'l':close_low_o}) #'ds': timestamp, ,'t':timestamp_arr_o

df = df[['y','h','o','l']] 


 
scaler = MinMaxScaler()
scaled_data = scaler.fit_transform(df)
 


All work good until here:

total_dataset = df.values
model_inputs = total_dataset[len(total_dataset) - test_data - prediction_days:]
print(model_inputs) 
model_inputs = model_inputs.reshape(-1, 1)  
model_inputs = scaler.transform(model_inputs)

In line 162 always receive follow error:

ValueError: X has 1 features, but MinMaxScaler is expecting 4 features as input.

CodePudding user response:

Need to change transform on fit_transform

model_inputs = scaler.fit_transform(model_inputs)
  • Related