小编Raf*_*nez的帖子

在Python中使用while函数将短语更改为向量

我想将以下短语更改为sklearn向量:

Article 1. It is not good to eat pizza after midnight
Article 2. I wouldn't survive a day withouth stackexchange
Article 3. All of these are just random phrases
Article 4. To prove if my experiment works.
Article 5. The red dog jumps over the lazy fox
Run Code Online (Sandbox Code Playgroud)

我得到以下代码:

from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer(min_df=1)

n=0
while n < 5:
   n = n + 1
   a = ('Article %(number)s' % {'number': n})
   print(a)
   with open("LISR2.txt") as openfile:
     for line …
Run Code Online (Sandbox Code Playgroud)

python scikit-learn

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

标签 统计

python ×1

scikit-learn ×1