小编Leo*_*eo 的帖子

矢量化器 fit_transform 在 sklearn 中如何工作?

我试图理解下面的代码

from sklearn.feature_extraction.text import CountVectorizer 

vectorizer = CountVectorizer() 

corpus = ['This is the first document.','This is the second second document.','And the third one.','Is this the first document?'] 

X = vectorizer.fit_transform(corpus)
Run Code Online (Sandbox Code Playgroud)

当我尝试打印 X 以查看将返回什么时,我得到了以下结果:

(0, 1)  1

(0, 2)  1

(0, 6)  1

(0, 3)  1

(0, 8)  1

(1, 5)  2

(1, 1)  1

(1, 6)  1

(1, 3)  1

(1, 8)  1

(2, 4)  1

(2, 7)  1

(2, 0)  1

(2, 6)  1

(3, 1)  1

(3, 2) …
Run Code Online (Sandbox Code Playgroud)

python machine-learning scikit-learn

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

machine-learning ×1

python ×1

scikit-learn ×1