harpomaxx commited on
Commit
f64df1e
1 Parent(s): 7eaf0d5

Update dga-detector.py

Browse files
Files changed (1) hide show
  1. dga-detector.py +37 -1
dga-detector.py CHANGED
@@ -31,7 +31,7 @@ class MyDataset(datasets.GeneratorBasedBuilder):
31
  for split in ["train", "test", "validation"]
32
  ]
33
 
34
- def _generate_examples(
35
  self,
36
  filepath: str,
37
  split: str,
@@ -47,3 +47,39 @@ class MyDataset(datasets.GeneratorBasedBuilder):
47
  "domain": row["domain"],
48
  "label": row["label"],
49
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  for split in ["train", "test", "validation"]
32
  ]
33
 
34
+ def _generate_examples_old(
35
  self,
36
  filepath: str,
37
  split: str,
 
47
  "domain": row["domain"],
48
  "label": row["label"],
49
  }
50
+
51
+
52
+ def _generate_examples(
53
+ self,
54
+ filepath: str,
55
+ split: str,
56
+ ):
57
+ # Read your CSV dataset
58
+ dataset = pd.read_csv(filepath)
59
+
60
+ # Get the total number of rows
61
+ total_rows = len(dataset)
62
+
63
+ # Define the ratio for train, test, and validation splits
64
+ train_ratio = 0.7
65
+ test_ratio = 0.2
66
+
67
+ # Calculate the indices for each split
68
+ train_end = int(train_ratio * total_rows)
69
+ test_end = train_end + int(test_ratio * total_rows)
70
+
71
+ # Filter your dataset based on the 'split' argument
72
+ if split == "train":
73
+ dataset = dataset.iloc[:train_end]
74
+ elif split == "test":
75
+ dataset = dataset.iloc[train_end:test_end]
76
+ elif split == "validation":
77
+ dataset = dataset.iloc[test_end:]
78
+
79
+ # Generate examples
80
+ for index, row in dataset.iterrows():
81
+ yield index, {
82
+ "domain": row["domain"],
83
+ "label": row["label"],
84
+ }
85
+