Download batch_test.py from prelington/acoli-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/datasets/prelington/acoli-dataset/resolve/main/batch_test.py
- Command line
-
hf download hf://datasets/prelington/acoli-dataset/batch_test.py
-
curl -L -o batch_test.py https://huggingface.co/datasets/prelington/acoli-dataset/resolve/main/batch_test.py
1.31 kB
| #!/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() |