Datasets:
Marcio Monteiro
commited on
Commit
·
f03698d
1
Parent(s):
fc90f11
feat: unsplitting data into train and test set
Browse files- .gitignore +1 -2
- 20newsgroups.csv +3 -0
- convert.py +0 -15
.gitignore
CHANGED
|
@@ -1,3 +1,2 @@
|
|
| 1 |
20news-19997.tar.gz
|
| 2 |
-
20_newsgroups/
|
| 3 |
-
20newsgroups.csv
|
|
|
|
| 1 |
20news-19997.tar.gz
|
| 2 |
+
20_newsgroups/
|
|
|
20newsgroups.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:455f8305fed7bee443348db3c0e7d017a118ca73299527f8be3b0a05efb71209
|
| 3 |
+
size 36689935
|
convert.py
CHANGED
|
@@ -10,10 +10,6 @@ import csv
|
|
| 10 |
import os
|
| 11 |
import re
|
| 12 |
|
| 13 |
-
import pandas as pd
|
| 14 |
-
|
| 15 |
-
from sklearn.model_selection import train_test_split
|
| 16 |
-
|
| 17 |
|
| 18 |
DATASET_PATH = "20_newsgroups"
|
| 19 |
OUTPUT_FILE = "20newsgroups.csv"
|
|
@@ -42,7 +38,6 @@ def run():
|
|
| 42 |
rows.append(doc)
|
| 43 |
|
| 44 |
save_csv(rows)
|
| 45 |
-
split_csv_train_test(test_size=0.2, random_state=42)
|
| 46 |
|
| 47 |
|
| 48 |
def read_document(class_name, doc_name):
|
|
@@ -69,16 +64,6 @@ def save_csv(rows, fname=OUTPUT_FILE):
|
|
| 69 |
writer.writerow(row)
|
| 70 |
|
| 71 |
|
| 72 |
-
def split_csv_train_test(**kwargs):
|
| 73 |
-
"""
|
| 74 |
-
Split the data into training and testing sets.
|
| 75 |
-
"""
|
| 76 |
-
df = pd.read_csv(OUTPUT_FILE)
|
| 77 |
-
train_df, test_df = train_test_split(df, **kwargs)
|
| 78 |
-
train_df.to_csv(TRAIN_OUTPUT_FILE, index=False)
|
| 79 |
-
test_df.to_csv(TEST_OUTPUT_FILE, index=False)
|
| 80 |
-
|
| 81 |
-
|
| 82 |
def parse_document(doc):
|
| 83 |
"""
|
| 84 |
Parses a document into a dictionary
|
|
|
|
| 10 |
import os
|
| 11 |
import re
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
DATASET_PATH = "20_newsgroups"
|
| 15 |
OUTPUT_FILE = "20newsgroups.csv"
|
|
|
|
| 38 |
rows.append(doc)
|
| 39 |
|
| 40 |
save_csv(rows)
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
def read_document(class_name, doc_name):
|
|
|
|
| 64 |
writer.writerow(row)
|
| 65 |
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
def parse_document(doc):
|
| 68 |
"""
|
| 69 |
Parses a document into a dictionary
|