fetch_20newsgroups_vectorized
- sklearn.datasets.fetch_20newsgroups_vectorized(*, subset='train', remove=(), data_home=None, download_if_missing=True, return_X_y=False, normalize=True, , ,
Load and vectorize the 20 newsgroups dataset (classification).
Download it if necessary.
This is a convenience function; the transformation is done using the
default settings for
CountVectorizer. For more
advanced usage (stopword filtering, n-gram extraction, etc.), combine
fetch_20newsgroups with a custom
CountVectorizer,
HashingVectorizer,
TfidfTransformer or
TfidfVectorizer.
The resulting counts are normalized using
sklearn.preprocessing.normalize unless normalize is set to False.
Classes | 20 |
Samples total | 18846 |
Dimensionality | 130107 |
Features | real |
Read more in the User Guide.
Select the dataset to load: ‘train’ for the training set, ‘test’ for the test set, ‘all’ for both, with shuffled ordering.
May contain any subset of (‘headers’, ‘footers’, ‘quotes’). Each of these are kinds of text that will be detected and removed from the newsgroup posts, preventing classifiers from overfitting on metadata.
‘headers’ removes newsgroup headers, ‘footers’ removes blocks at the ends of posts that look like signatures, and ‘quotes’ removes lines that appear to be quoting another post.
Specify a download and cache folder for the datasets. If None, all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
If False, raise an OSError if the data is not locally available instead of trying to download the data from the source site.
>>> from sklearn.datasets import fetch_20newsgroups_vectorized
>>> newsgroups_vectorized = fetch_20newsgroups_vectorized(subset='test')
>>> newsgroups_vectorized.data.shape
(7532, 130107)
>>> newsgroups_vectorized.target.shape
(7532,)
Multiclass sparse logistic regression on 20newgroups
The Johnson-Lindenstrauss bound for embedding with random projections
If True, returns (data.data, data.target) instead of a Bunch
object.
If True, normalizes each document’s feature vector to unit norm using
sklearn.preprocessing.normalize.
If True, the data is a pandas DataFrame including columns with
appropriate dtypes (numeric, string, or categorical). The target is
a pandas DataFrame or Series depending on the number of
target_columns.
Number of retries when HTTP errors are encountered.
Number of seconds between retries.
BunchDictionary-like object, with the following attributes.
The input data matrix. If as_frame is True, data is
a pandas DataFrame with sparse columns.
The target labels. If as_frame is True, target is a
pandas Series.
The names of target classes.
The full description of the dataset.
Only present when as_frame=True. Pandas DataFrame with data
and target.
return_X_y is Truedata and target would be of the format defined in the Bunch
description above.