Update make_data.py
Browse files- make_data.py +37 -11
make_data.py
CHANGED
|
@@ -1,22 +1,48 @@
|
|
| 1 |
import pandas as pd
|
|
|
|
| 2 |
|
| 3 |
-
df = pd.read_csv("hbl_nadra_clean.csv")
|
| 4 |
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
print("\nColumns:")
|
| 9 |
-
print(df.columns)
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
print("\nPipe distribution Urdu:")
|
| 13 |
-
print(df["urdu"].str.count(r"\|").value_counts())
|
| 14 |
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
print("\nPipe distribution Roman:")
|
| 17 |
-
print(df["roman"].str.count(r"\|").value_counts())
|
| 18 |
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
+
from sklearn.model_selection import train_test_split
|
| 3 |
|
|
|
|
| 4 |
|
| 5 |
+
DATA_PATH = "hbl_nadra_clean.csv"
|
| 6 |
|
| 7 |
+
# ============================================================
|
| 8 |
+
# LIMIT ROWS FOR EXPERIMENTS
|
| 9 |
+
# Set to None for full dataset
|
| 10 |
+
# Example: 50000 for testing
|
| 11 |
+
# ============================================================
|
| 12 |
+
LIMIT_ROWS = None
|
| 13 |
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
df = pd.read_csv(DATA_PATH)
|
| 16 |
|
|
|
|
|
|
|
| 17 |
|
| 18 |
+
if LIMIT_ROWS:
|
| 19 |
+
df = df.head(LIMIT_ROWS)
|
| 20 |
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
print("Total rows:", len(df))
|
| 23 |
|
| 24 |
+
|
| 25 |
+
# ============================================================
|
| 26 |
+
# TRAIN / VALIDATION / TEST SPLIT
|
| 27 |
+
# 95% train
|
| 28 |
+
# 3% validation
|
| 29 |
+
# 2% test
|
| 30 |
+
# ============================================================
|
| 31 |
+
|
| 32 |
+
train_df, temp_df = train_test_split(
|
| 33 |
+
df,
|
| 34 |
+
test_size=0.05,
|
| 35 |
+
random_state=42
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
val_df, test_df = train_test_split(
|
| 40 |
+
temp_df,
|
| 41 |
+
test_size=0.40,
|
| 42 |
+
random_state=42
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
print("Train:", len(train_df))
|
| 47 |
+
print("Validation:", len(val_df))
|
| 48 |
+
print("Test:", len(test_df))
|