how to convert 2d array into 1d array after minmax scaling

Viewed 240

I did my feature minmax scaling, previously the shape is (10000,) after i scaled it with MinMaxScaler it the shape changed into (10000,1). I need the shape to be (10000,) or else somehow my Keras model cannot process it due to different shape of the dimension. How to turn the shape into (10000,) again?

2 Answers

here a possibility

import numpy as np
from sklearn.preprocessing import MinMaxScaler

X = np.random.uniform(-10,10, 10000)
print(X.shape) # (10000,)

scaler = MinMaxScaler()
scaled_X = scaler.fit_transform(X.reshape(-1,1))
print(scaled_X.shape) # (10000,1)

scaled_X = scaled_X.ravel()
print(scaled_X.shape) # (10000,)

you can try using this, I don't know if this is helpful but I thought to post it.

a = a.reshape(12,1)
print(a.shape)
array_1d = a.flatten()
print(array_1d.shape)

output

(12, 1)
(12,)
Related