-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit_data.py
More file actions
29 lines (22 loc) · 774 Bytes
/
split_data.py
File metadata and controls
29 lines (22 loc) · 774 Bytes
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
import pandas as pd
from sklearn.model_selection import train_test_split
import os
BASE_DIR = "/home/azureuser/packet_loss_project"
DATA_DIR = f"{BASE_DIR}/data"
os.makedirs(DATA_DIR, exist_ok=True)
# ✅ READ from project root
data = pd.read_csv(f"{BASE_DIR}/final_dataset.csv")
# Keep only required columns
data = data[["rtt_avg_ms", "jitter_ms", "throughput_mbps"]]
# 70% Train / 30% Test split
train_df, test_df = train_test_split(
data,
test_size=0.30,
random_state=42
)
# ✅ WRITE into data/ folder
train_df.to_csv(f"{DATA_DIR}/train_dataset.csv", index=False)
test_df.to_csv(f"{DATA_DIR}/test_dataset.csv", index=False)
print("✅ Dataset split completed successfully")
print("Training set:", train_df.shape)
print("Testing set :", test_df.shape)