Add .gitignore file and main.py script
Browse files- .gitignore +3 -0
- main.py +24 -0
.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
**/venv
|
2 |
+
**/__pycache__
|
3 |
+
**/.DS_Store
|
main.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import load_dataset, DatasetDict
|
2 |
+
|
3 |
+
# Load your dataset from a local JSONL file
|
4 |
+
dataset = load_dataset("json", data_files="listing.jsonl")
|
5 |
+
|
6 |
+
# Split the dataset into train and temp
|
7 |
+
split_dataset = dataset["train"].train_test_split(test_size=0.3)
|
8 |
+
|
9 |
+
train_dataset = split_dataset["train"]
|
10 |
+
temp_dataset = split_dataset["test"]
|
11 |
+
|
12 |
+
# Split the temp dataset into validation and test
|
13 |
+
split_temp_dataset = temp_dataset.train_test_split(test_size=0.2)
|
14 |
+
|
15 |
+
validation_dataset = split_temp_dataset["train"]
|
16 |
+
test_dataset = split_temp_dataset["test"]
|
17 |
+
|
18 |
+
# Combine all splits into a DatasetDict
|
19 |
+
final_dataset = DatasetDict(
|
20 |
+
{"train": train_dataset, "validation": validation_dataset, "test": test_dataset}
|
21 |
+
)
|
22 |
+
|
23 |
+
# Save the split datasets to disk
|
24 |
+
final_dataset.save_to_disk("listing.jsonl")
|