susanli2016 / Machine-Learning-with-Python

Python code for common Machine Learning Algorithms
4.31k stars 4.82k forks source link

Expected 2D array, got 1D array instead #16

Open guireif opened 5 years ago

guireif commented 5 years ago

Hi,

I'm getting the following error when I run the following cell What should I do?

scaler = MinMaxScaler(feature_range=(-1, 1)) train_sc = scaler.fit_transform(train) test_sc = scaler.transform(test)

Expected 2D array, got 1D array instead: array=[17.24 18.190001 19.219999 ... 10.47 10.18 11.04 ]. Reshape your data either using array.reshape(-1, 1)

taufique1929 commented 5 years ago

scaler = MinMaxScaler(feature_range=(-1,1)) train = np.asarray(train).reshape(-1,1) test = np.asarray(test).reshape(-1,1) train_sc = scaler.fit_transform(train) test_sc = scaler.transform(test)