Datasets:
File size: 2,893 Bytes
7f34860 887d862 7f34860 7ca1d13 887d862 7f34860 887d862 7b26c6b 7f34860 7b26c6b cff203d 7b26c6b 30af376 7b26c6b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
---
dataset_info:
- config_name: default
features:
- name: utterance
dtype: string
- name: label
sequence: int64
splits:
- name: train
num_bytes: 26416704
num_examples: 20856
download_size: 18117453
dataset_size: 34001126.59570387
- config_name: intents
features:
- name: id
dtype: int64
- name: name
dtype: string
- name: tags
sequence: 'null'
- name: regexp_full_match
sequence: 'null'
- name: regexp_partial_match
sequence: 'null'
- name: description
dtype: 'null'
splits:
- name: intents
num_bytes: 1924
num_examples: 65
download_size: 3851
dataset_size: 1924
configs:
- config_name: default
data_files:
- split: train
path: data/train-*
- config_name: intents
data_files:
- split: intents
path: intents/intents-*
task_categories:
- text-classification
language:
- en
---
# reuters
This is a text classification dataset. It is intended for machine learning research and experimentation.
This dataset is obtained via formatting another publicly available data to be compatible with our [AutoIntent Library](https://deeppavlov.github.io/AutoIntent/index.html).
## Usage
It is intended to be used with our [AutoIntent Library](https://deeppavlov.github.io/AutoIntent/index.html):
```python
from autointent import Dataset
reuters = Dataset.from_hub("AutoIntent/reuters")
```
## Source
This dataset is taken from `ucirvine/reuters21578` and formatted with our [AutoIntent Library](https://deeppavlov.github.io/AutoIntent/index.html):
```python
from collections import defaultdict
from datasets import load_dataset
from autointent import Dataset
# load original data
reuters = load_dataset("ucirvine/reuters21578", "ModHayes", trust_remote_code=True)
# remove low-resource classes
counter = defaultdict(int)
for batch in reuters["train"].iter(batch_size=16):
for labels in batch["topics"]:
for lab in labels:
counter[lab] += 1
names_to_remove = [name for name, cnt in counter.items() if cnt < 10]
intent_names = sorted(set(name for intents in reuters["train"]["topics"] for name in intents))
for n in names_to_remove:
intent_names.remove(n)
name_to_id = {name: i for i, name in enumerate(intent_names)}
# extract only texts and labels
def transform(example: dict):
return {
"utterance": example["text"],
"label": [name_to_id[intent_name] for intent_name in example["topics"] if intent_name not in names_to_remove],
}
multilabel_reuters = reuters["train"].map(transform, remove_columns=reuters["train"].features.keys())
# if any out-of-scope samples
res = multilabel_reuters.to_list()
for sample in res:
if len(sample["label"]) == 0:
sample.pop("label")
# format
intents = [{"id": i, "name": name} for i, name in enumerate(intent_names)]
reuters_converted = Dataset.from_dict({"intents": intents, "train": res})
```
|