From 63e29fa7908b004e5759d96c091af73457e10c0a Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Thu, 1 Feb 2024 11:21:36 -0500 Subject: [PATCH 1/2] fetch_20_news_groups --- sklearn/datasets/_twenty_newsgroups.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sklearn/datasets/_twenty_newsgroups.py b/sklearn/datasets/_twenty_newsgroups.py index 22ac716871cc2..09735cde6b745 100644 --- a/sklearn/datasets/_twenty_newsgroups.py +++ b/sklearn/datasets/_twenty_newsgroups.py @@ -262,6 +262,19 @@ def fetch_20newsgroups( (n_samples,) contains the target samples. .. versionadded:: 0.22 + + Examples + -------- + >>> 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]) """ data_home = get_data_home(data_home=data_home) From a50804a34a872858d481f9f4e5ca846dd1a79b99 Mon Sep 17 00:00:00 2001 From: Guillaume Lemaitre Date: Sat, 2 Mar 2024 14:42:25 +0100 Subject: [PATCH 2/2] fix --- sklearn/datasets/_twenty_newsgroups.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sklearn/datasets/_twenty_newsgroups.py b/sklearn/datasets/_twenty_newsgroups.py index de923b73418bf..e1ca9bb0fa5cd 100644 --- a/sklearn/datasets/_twenty_newsgroups.py +++ b/sklearn/datasets/_twenty_newsgroups.py @@ -285,6 +285,7 @@ def fetch_20newsgroups( 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)