Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve DataConversion Warning with MinMax normalization

Can anybody tell me how i can remove the below warning? I want to normalize a set of integer values by min-max normalization technique but i am getting this warning and don't know how to solve it? (X is a column of integer values starting from 0 to 127)

Here is the code:

X = df.iloc[:,0]
mms = MinMaxScaler()
a=X.reshape(-1, 1)
b=mms.fit_transform(a)
sns.set(color_codes=True)
np.random.seed(sum(map(ord, "distributions")))
ax=sns.distplot(b);
ax.set(xlabel='frequency', ylabel='Probability')
plt.show()

And here is the warning:

DataConversionWarning: Data with input dtype int64 was converted to float64 by MinMaxScaler. warnings.warn(msg, DataConversionWarning)
like image 339
Shelly Avatar asked Apr 13 '26 20:04

Shelly


1 Answers

MinMaxScaler() works using float numbers, so it will automatically convert your np.array of type np.int to np.float and inform you about it. If you don't want to see this warning, do the conversion explicitly beforehand:

b = mms.fit_transform(a.astype(np.float))
like image 112
Jorge Avatar answered Apr 16 '26 09:04

Jorge