prelington commited on
Commit
91ff650
·
verified ·
1 Parent(s): f74f3c2

Create batch_test.py

Browse files
Files changed (1) hide show
  1. batch_test.py +40 -0
batch_test.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ from model import AcoliModel
3
+ import json
4
+
5
+ def batch_test():
6
+ print("Loading model and test data...")
7
+ model = AcoliModel("./acoli-model")
8
+
9
+ # Test with first 10 examples from your dataset
10
+ test_samples = []
11
+ with open('../acoli-dataset/data.jsonl', 'r', encoding='utf-8') as f:
12
+ for i, line in enumerate(f):
13
+ if i >= 10: # Test only first 10 samples
14
+ break
15
+ data = json.loads(line)
16
+ test_samples.append(data)
17
+
18
+ print(f"\n=== Batch Testing on {len(test_samples)} samples ===")
19
+
20
+ correct = 0
21
+ for i, sample in enumerate(test_samples, 1):
22
+ text = sample['text']
23
+ true_label = sample['label']
24
+
25
+ prediction = model.predict(text)
26
+ predicted_label = int(prediction[0]['label'].split('_')[-1])
27
+
28
+ is_correct = (predicted_label == true_label)
29
+ if is_correct:
30
+ correct += 1
31
+
32
+ status = "✅" if is_correct else "❌"
33
+ print(f"{status} Sample {i}: True={true_label}, Predicted={predicted_label}")
34
+ print(f" Text: {text[:60]}...")
35
+
36
+ accuracy = correct / len(test_samples) * 100
37
+ print(f"\n📊 Accuracy: {correct}/{len(test_samples)} ({accuracy:.1f}%)")
38
+
39
+ if __name__ == "__main__":
40
+ batch_test()