Load the filenames and data from the 20 newsgroups dataset (classification).
Download it if necessary.
Read more in the User Guide.
Specify a download and cache folder for the datasets. If None, all scikit-learn data is stored in ‘~/scikit_learn_data’ subfolders.
Select the dataset to load: ‘train’ for the training set, ‘test’ for the test set, ‘all’ for both, with shuffled ordering.
If None (default), load all the categories. If not None, list of category names to load (other categories ignored).
Whether or not to shuffle the data: might be important for models that make the assumption that the samples are independent and identically distributed (i.i.d.), such as stochastic gradient descent.
Determines random number generation for dataset shuffling. Pass an int for reproducible output across multiple function calls. See Glossary.
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.
‘headers’ follows an exact standard; the other filters are not always correct.
If False, raise an OSError if the data is not locally available instead of trying to download the data from the source site.
If True, returns (data.data, data.target)
instead of a Bunch object.
Added in version 0.22.
Number of retries when HTTP errors are encountered.
Added in version 1.5.
Number of seconds between retries.
Added in version 1.5.
Bunch
Dictionary-like object, with the following attributes.
The data list to learn.
The target labels.
The path to the location of the data.
The full description of the dataset.
The names of target classes.
return_X_y=True
A tuple of two ndarrays. The first contains a 2D array of shape (n_samples, n_classes) with each row representing one sample and each column representing the features. The second array of shape (n_samples,) contains the target samples.
Added in version 0.22.
Examples
>>> from sklearn.datasets import fetch_20newsgroups >>> cats = ['alt.atheism', 'sci.space'] >>> newsgroups_train = fetch_20newsgroups(subset='train', categories=cats) >>> list(newsgroups_train.target_names) ['alt.atheism', 'sci.space'] >>> newsgroups_train.filenames.shape (1073,) >>> newsgroups_train.target.shape (1073,) >>> newsgroups_train.target[:10] array([0, 1, 1, 1, 0, 1, 1, 0, 0, 0])
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4