sklearn.datasets.fetch_20newsgroups_vectorized?

sklearn.datasets.fetch_20newsgroups_vectorized(*, subset='train', remove=(), data_home=None, download_if_missing=True, return_X_y=False, normalize=True)

[源碼]

加載20個新聞組數據集并將其向量化為令牌計數(分類)。

如有必要,請下載。

這是一種便利功能; 轉換是使用sklearn.feature_extraction.text.CountVectorizer的默認設置完成的。 對于更高級的用法(停用詞過濾,n-gram提取等),請將fetch_20newsgroups與自定義組合

sklearn.feature_extraction.text.CountVectorizer, sklearn.feature_extraction.text.HashingVectorizer, sklearn.feature_extraction.text.TfidfTransformer 或者 sklearn.feature_extraction.text.TfidfVectorizer.

除非將normalize設置為False,否則使用sklearn.preprocessing.normalize對結果計數進行標準化。

20
樣本總數 18846
維度 130107
特征 real

用戶指南中閱讀更多內容。

參數 說明
subset ‘train’ or ‘test’, ‘all’, optional
選擇要加載的數據集:“train”用于訓練集,“test”用于測試集,“all”用于兩者,并按隨機順序排序。
remove tuple
可以包含(“headers”,“footers”,“quotes”)的任何子集。 這些文本中的每一種都是將被檢測到并從新聞組帖子中刪除的文本,從而防止分類器過度適合元數據。

“headers”刪除新聞組頁眉,“footers”刪除帖子結尾處看起來像簽名的塊,“quotes”刪除看起來像是引用另一篇文章的行。
data_home optional, default: None
指定數據集的下載和緩存文件夾。 如果為None,則所有scikit-learn數據都存儲在“?/ scikit_learn_data”子文件夾中。
download_if_missing optional, True by default
如果為False,則在數據不在本地可用時引發IOError,而不是嘗試從源站點下載數據。
return_X_y bool, default=False
如果為True,則返回(data.data,data.target)而不是Bunch對象。

0.20版中的新功能。
normalize bool, default=True
如果為True,則使用sklearn.preprocessing.normalize將每個文檔的特征向量標準化為單位范數。

0.22版中的新功能。
返回值 說明
bunch Bunch
類字典對象,具有以下屬性。
- data: sparse matrix, shape [n_samples, n_features]
要學習的數據矩陣。
- target: array, shape [n_samples]
目標標簽。
- target_names: list, length [n_classes]
目標類的名稱。
- DESCR: str
數據集的完整描述。
(data, target) tuple if return_X_y is True
0.20版中的新功能。