回答編集履歴

2

修正

2019/04/16 04:35

投稿

sequelanonymous
sequelanonymous

スコア123

test CHANGED
@@ -1,6 +1,8 @@
1
1
  [countvectorizer](https://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.CountVectorizer.html#sklearn.feature_extraction.text.CountVectorizer)を利用することで本題の質問の本質を解決しました。
2
2
 
3
3
 
4
+
5
+ tfのデータ個数は以下。
4
6
 
5
7
  ```python
6
8
 
@@ -25,3 +27,21 @@
25
27
  print(word, count)
26
28
 
27
29
  ```
30
+
31
+
32
+
33
+ idfのデータ個数は以下。
34
+
35
+ ```
36
+
37
+ from sklearn.feature_extraction.text import TfidfVectorizer
38
+
39
+ t_vec = TfidfVectorizer(token_pattern=r"(?u)\b\w\w+\b")
40
+
41
+
42
+
43
+ len(t_vec.vocabulary_)
44
+
45
+ len(t_vec.idf_)
46
+
47
+ ```

1

誤字

2019/04/16 04:35

投稿

sequelanonymous
sequelanonymous

スコア123

test CHANGED
@@ -22,6 +22,6 @@
22
22
 
23
23
  for word, count in zip(c_vec.get_feature_names(), one_hot_vector_count):
24
24
 
25
- print(word.sorted, count)
25
+ print(word, count)
26
26
 
27
27
  ```