Source with warming
where np_matrix is a NumPy Matrix of 100 rows by 5 columns consisting of random integers from 1-100.
from sklearn.preprocessing import MinMaxScaler
scaler_model = MinMaxScaler()
scaler_model.fit(np_matrix)
scaler_model.transform(np_matrix)
Updated code
from sklearn.preprocessing import MinMaxScaler
scaler_model = MinMaxScaler()
scaler_model.fit(np_matrix.astype(float))
scaler_model.transform(np_matrix)
Reference
https://stackoverflow.com/questions/39214164/data-conversion-error-while-applying-a-function-to-each-row-in-pandas-python
Thanks, it helped.
ReplyDeleteHowever, does it impact anywhere in further processing... like if datatype of "age" always is integer and using astype(float) for normalizing. Is it good to use astype float for the features which are integer?