Download examples/preprocess/samples_count.py from intelli-zen/spam_detect: direct link, hf CLI and curl.
- Browser
- Download file 903 Bytes
-
https://huggingface.co/datasets/intelli-zen/spam_detect/resolve/main/examples/preprocess/samples_count.py
- Command line
-
hf download hf://datasets/intelli-zen/spam_detect/examples/preprocess/samples_count.py
-
curl -L -o samples_count.py https://huggingface.co/datasets/intelli-zen/spam_detect/resolve/main/examples/preprocess/samples_count.py
903 Bytes
| #!/usr/bin/python3 | |
| # -*- coding: utf-8 -*- | |
| from collections import defaultdict | |
| from datasets import load_dataset, DownloadMode | |
| dataset_dict = load_dataset( | |
| "../../spam_detect.py", | |
| # name="enron_spam", | |
| # name="enron_spam_subset", | |
| # name="ling_spam", | |
| # name="sms_spam", | |
| # name="spam_assassin", | |
| # name="spam_detection", | |
| # name="sms_spam_collection", | |
| # name="spam_message", | |
| # name="spam_message_lr", | |
| name="trec07p", | |
| # name="youtube_spam_collection", | |
| split=None, | |
| cache_dir=None, | |
| download_mode=DownloadMode.FORCE_REDOWNLOAD | |
| ) | |
| counter = defaultdict(int) | |
| for split, dataset in dataset_dict.items(): | |
| for sample in dataset: | |
| text = sample["text"] | |
| label = sample["label"] | |
| counter[label] += 1 | |
| count = "; ".join(sorted(["{}: {}".format(k, v) for k, v in counter.items()])) | |
| print(count) | |
| if __name__ == '__main__': | |
| pass | |