本文整理汇总了Python中sklearn.feature_extraction.FeatureHasher.fit方法的典型用法代码示例。如果您正苦于以下问题:Python FeatureHasher.fit方法的具体用法?Python FeatureHasher.fit怎么用?Python FeatureHasher.fit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.feature_extraction.FeatureHasher
的用法示例。
在下文中一共展示了FeatureHasher.fit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plotCorr
# 需要导入模块: from sklearn.feature_extraction import FeatureHasher [as 别名]
# 或者: from sklearn.feature_extraction.FeatureHasher import fit [as 别名]
plt.plot(numberFeatures.iloc[:,4])
def plotCorr(data,number):
subData = data.iloc[number*1000:(number+1)*1000,:]
corrY = subData.corr()
plt.figure()
plt.imshow(corrY)
#plotCorr(numberFeatures,1)
#plotCorr(numberFeatures,2)
#%%
from sklearn.feature_extraction import FeatureHasher
hasher = FeatureHasher(input_type='string',dtype='float')
strFeature = hasher.fit(stringFeature).transform(stringFeature).toarray()
#%% normalizetoin
numberFeatures = numberFeatures.fillna(0)
from sklearn import preprocessing
scaler = preprocessing.StandardScaler().fit(numberFeatures.iloc[:,1:])
X_scaled = scaler.transform(numberFeatures.iloc[:,1:])
import numpy as np
#a = numpy.asarray([ [1,2,3], [4,5,6], [7,8,9] ])
#numpy.savetxt("/Users/weizhi/Downloads/kaggle competion/scared.csv", X_scaled, delimiter=",")
where_are_NaNs = np.isnan(X_scaled)
X_scaled[where_are_NaNs] = 0
#data = pd.read_csv("/Users/weizhi/Downloads/kaggle competion/scared.csv")
numberFeatures = None