标签:form from style int orm ESS numpy encoder nsf
1.数据预处理 二值化
import numpy as np from sklearn import preprocessing X = np.array([[1., -1., 2.], [2., 0., 0.], [0., 1., -1.]]) binarized = preprocessing.Binarizer().fit(X) print(binarized.transform(X))
2.数据预处理 Onehot处理离散数据
import numpy as np from sklearn import preprocessing Y = np.array([[0, 1, 0], [1, 0, 1], [2, 2, 1], [3, 1, 0]]) enc = preprocessing.OneHotEncoder() enc.fit(Y) print(enc.transform([[3, 0, 1]]).toarray())
标签:form from style int orm ESS numpy encoder nsf
原文地址:https://www.cnblogs.com/leokale-zz/p/11032550.html