File size: 1,313 Bytes
91ff650 |
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 30 31 32 33 34 35 36 37 38 39 40 |
#!/usr/bin/env python3
from model import AcoliModel
import json
def batch_test():
print("Loading model and test data...")
model = AcoliModel("./acoli-model")
# Test with first 10 examples from your dataset
test_samples = []
with open('../acoli-dataset/data.jsonl', 'r', encoding='utf-8') as f:
for i, line in enumerate(f):
if i >= 10: # Test only first 10 samples
break
data = json.loads(line)
test_samples.append(data)
print(f"\n=== Batch Testing on {len(test_samples)} samples ===")
correct = 0
for i, sample in enumerate(test_samples, 1):
text = sample['text']
true_label = sample['label']
prediction = model.predict(text)
predicted_label = int(prediction[0]['label'].split('_')[-1])
is_correct = (predicted_label == true_label)
if is_correct:
correct += 1
status = "✅" if is_correct else "❌"
print(f"{status} Sample {i}: True={true_label}, Predicted={predicted_label}")
print(f" Text: {text[:60]}...")
accuracy = correct / len(test_samples) * 100
print(f"\n📊 Accuracy: {correct}/{len(test_samples)} ({accuracy:.1f}%)")
if __name__ == "__main__":
batch_test() |