【发布时间】:2014-09-03 20:22:39
【问题描述】:
我在 scikit-learn 中使用 FeatureHasher。
谁能解释为什么我在稀疏矩阵中得到 4 个非零数据,而不是在以下之后的 2 个:
>>> f = FeatureHasher(input_type='string')
>>> g = f.transform(('as','bs'))
<2x1048576 sparse matrix of type '<type 'numpy.float64'>'
with 4 stored elements in Compressed Sparse Row format>
>>> g.data
array([-1., 1., -1., -1.])
>>> g.nonzero()
(array([0, 0, 1, 1], dtype=int32), array([341263, 354738, 98813, 341263], dtype=int32))
【问题讨论】:
标签: python machine-learning scikit-learn