Monday, October 23, 2017

[Python][Resolved] DataConversionWarning: Data with input dtype int32 was converted to float64 by MinMaxScaler. warnings.warn(msg, DataConversionWarning)

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

1 comment :

  1. Thanks, it helped.
    However, 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?

    ReplyDelete