sklearn 中 fit fit_transform

fit(y) Fit label encoder
fit_transform(y) Fit label encoder and return encoded labels
fit 返回一个实例
fit_transform 返回 和y一样的形状

from sklearn import preprocessing
le = preprocessing.LabelEncoder()
city = le.fit_transform(["paris", "paris", "tokyo", "amsterdam"])
print city

得到一列 [1 1 2 0]

from sklearn import preprocessing
le = preprocessing.LabelEncoder()
city = le.fit(["paris", "paris", "tokyo", "amsterdam"])
print city

得到LabelEncoder()

http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.LabelEncoder.html#sklearn.preprocessing.LabelEncoder.fit_transform

你可能感兴趣的:(sklearn的问题)