imbesat-rizvi commited on
Commit
1de8e5a
1 Parent(s): 85619b5

Initial Commit of the 20-Newsgroup dataset with groupname as labels and split into train, validation and test sets.

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. README.md +3 -0
  3. dataset_info.json +1 -0
  4. newsgroups.py +88 -0
  5. newsgroups.zip +3 -0
.gitattributes CHANGED
@@ -35,3 +35,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
35
  *.mp3 filter=lfs diff=lfs merge=lfs -text
36
  *.ogg filter=lfs diff=lfs merge=lfs -text
37
  *.wav filter=lfs diff=lfs merge=lfs -text
 
 
35
  *.mp3 filter=lfs diff=lfs merge=lfs -text
36
  *.ogg filter=lfs diff=lfs merge=lfs -text
37
  *.wav filter=lfs diff=lfs merge=lfs -text
38
+ newsgroups.zip filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,6 @@
1
  ---
2
  license: mit
 
3
  ---
 
 
 
1
  ---
2
  license: mit
3
+ pretty_name: 20-Newsgroups
4
  ---
5
+
6
+ # Dataset Card for "20-Newsgroups"
dataset_info.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"description": "\nThe bydate version of the 20-newsgroup dataset fetched from scikit_learn and split in stratified manner into train, validation and test sets. The test set from the original 20 newsgroup dataset is retained while the original train set is split 80:20 into train and validation sets in stratified manner based on the newsgroup. The 20 different newsgroup are provided as the labels instead of config names as specified in the official huggingface dataset. Newsgroups are specified as labels to provide a simplified setup for text classification task. The 20 different newsgroup functioning as labels are:\n(1) alt.atheism\n(2) comp.graphics\n(3) comp.os.ms-windows.misc\n(4) comp.sys.ibm.pc.hardware\n(5) comp.sys.mac.hardware\n(6) comp.windows.x\n(7) misc.forsale\n(8) rec.autos\n(9) rec.motorcycles\n(10) rec.sport.baseball\n(11) rec.sport.hockey\n(12) sci.crypt\n(13) sci.electronics\n(14) sci.med\n(15) sci.space\n(16) soc.religion.christian\n(17) talk.politics.guns\n(18) talk.politics.mideast\n(19) talk.politics.misc\n(20) talk.religion.misc", "citation": "\n@inproceedings{Lang95,\n author = {Ken Lang},\n title = {Newsweeder: Learning to filter netnews}\n year = {1995}\n booktitle = {Proceedings of the Twelfth International Conference on Machine Learning}\n pages = {331-339}\n }\n ", "homepage": "http://qwone.com/~jason/20Newsgroups/", "license": "", "features": {"text": {"dtype": "large_string", "id": null, "_type": "Value"}, "labels": {"num_classes": 20, "names": ["alt.atheism", "comp.graphics", "comp.os.ms-windows.misc", "comp.sys.ibm.pc.hardware", "comp.sys.mac.hardware", "comp.windows.x", "misc.forsale", "rec.autos", "rec.motorcycles", "rec.sport.baseball", "rec.sport.hockey", "sci.crypt", "sci.electronics", "sci.med", "sci.space", "soc.religion.christian", "talk.politics.guns", "talk.politics.mideast", "talk.politics.misc", "talk.religion.misc"], "id": null, "_type": "ClassLabel"}}, "post_processed": null, "supervised_keys": null, "task_templates": null, "builder_name": "newsgroups", "config_name": "default", "version": {"version_str": "2.0.0", "description": null, "major": 2, "minor": 0, "patch": 0}, "splits": {"train": {"name": "train", "num_bytes": 17065029, "num_examples": 9051, "dataset_name": "newsgroups"}, "validation": {"name": "validation", "num_bytes": 4279761, "num_examples": 2263, "dataset_name": "newsgroups"}, "test": {"name": "test", "num_bytes": 13328728, "num_examples": 7532, "dataset_name": "newsgroups"}}, "download_checksums": {}, "download_size": 0, "post_processing_size": null, "dataset_size": 34673518, "size_in_bytes": 34673518}
newsgroups.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+ import pandas as pd
3
+
4
+ _NEWSGROUPS = [
5
+ 'alt.atheism',
6
+ 'comp.graphics',
7
+ 'comp.os.ms-windows.misc',
8
+ 'comp.sys.ibm.pc.hardware',
9
+ 'comp.sys.mac.hardware',
10
+ 'comp.windows.x',
11
+ 'misc.forsale',
12
+ 'rec.autos',
13
+ 'rec.motorcycles',
14
+ 'rec.sport.baseball',
15
+ 'rec.sport.hockey',
16
+ 'sci.crypt',
17
+ 'sci.electronics',
18
+ 'sci.med',
19
+ 'sci.space',
20
+ 'soc.religion.christian',
21
+ 'talk.politics.guns',
22
+ 'talk.politics.mideast',
23
+ 'talk.politics.misc',
24
+ 'talk.religion.misc',
25
+ ]
26
+
27
+ _DESCRIPTION = """
28
+ The bydate version of the 20-newsgroup dataset fetched from scikit_learn and split in stratified manner into train, validation and test sets. The test set from the original 20 newsgroup dataset is retained while the original train set is split 80:20 into train and validation sets in stratified manner based on the newsgroup. The 20 different newsgroup are provided as the labels instead of config names as specified in the official huggingface dataset. Newsgroups are specified as labels to provide a simplified setup for text classification task. The 20 different newsgroup functioning as labels are:
29
+ """
30
+ _DESCRIPTION += "\n".join(f"({i+1}) {j}" for i,j in enumerate(_NEWSGROUPS))
31
+
32
+ _HOMEPAGE = "http://qwone.com/~jason/20Newsgroups/"
33
+
34
+ _CITATION = """
35
+ @inproceedings{Lang95,
36
+ author = {Ken Lang},
37
+ title = {Newsweeder: Learning to filter netnews}
38
+ year = {1995}
39
+ booktitle = {Proceedings of the Twelfth International Conference on Machine Learning}
40
+ pages = {331-339}
41
+ }
42
+ """
43
+
44
+
45
+ class Newsgroups(datasets.GeneratorBasedBuilder):
46
+
47
+ VERSION = datasets.utils.Version("2.0.0")
48
+
49
+ def _info(self):
50
+
51
+ features = datasets.Features(
52
+ {
53
+ "text": datasets.Value("large_string"),
54
+ "labels": datasets.features.ClassLabel(names=_NEWSGROUPS),
55
+ }
56
+ )
57
+
58
+ return datasets.DatasetInfo(
59
+ description=_DESCRIPTION,
60
+ features=features,
61
+ supervised_keys=None,
62
+ homepage=_HOMEPAGE,
63
+ citation=_CITATION,
64
+ )
65
+
66
+
67
+ def _split_generators(self, dl_manager):
68
+ data_df = pd.read_csv("newsgroups.zip")
69
+ train_df = data_df.query(f"split == 'train'").drop(columns="split")
70
+ val_df = data_df.query(f"split == 'validation'").drop(columns="split")
71
+ test_df = data_df.query(f"split == 'test'").drop(columns="split")
72
+
73
+ return [
74
+ datasets.SplitGenerator(
75
+ name=datasets.Split.TRAIN, gen_kwargs={"df": train_df}
76
+ ),
77
+ datasets.SplitGenerator(
78
+ name=datasets.Split.VALIDATION, gen_kwargs={"df": val_df}
79
+ ),
80
+ datasets.SplitGenerator(
81
+ name=datasets.Split.TEST, gen_kwargs={"df": test_df}
82
+ ),
83
+ ]
84
+
85
+
86
+ def _generate_examples(self, df):
87
+ for idx, row in df.iterrows():
88
+ yield idx, row.to_dict()
newsgroups.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e18ecd06210a2a95a0c98a9e5be09c2c438be3cd10f66b3bdc85ccee3f153bfd
3
+ size 14404706