(self, index)
| 98 | print(f"Accuracy: {accuracy:.1%} ({correct}/{num_samples})") |
| 99 | |
| 100 | def test_specific_sample(self, index): |
| 101 | if index < 0 or index >= len(self.dataset): |
| 102 | print(f"Error: Index must be between 0 and {len(self.dataset)-1}") |
| 103 | return |
| 104 | |
| 105 | image, label = self.dataset[index] |
| 106 | pred_class, confidence, top5_idx, top5_prob = self.predict_image(image) |
| 107 | |
| 108 | print(f"\nSample #{index}") |
| 109 | print("-" * 60) |
| 110 | print(f"True Label: {self.classes[label]}") |
| 111 | print(f"Predicted: {self.classes[pred_class]}") |
| 112 | print(f"Confidence: {confidence:.2%}") |
| 113 | print(f"Status: {'✓ Correct' if pred_class == label else '✗ Wrong'}") |
| 114 | print("\nTop-5 Predictions:") |
| 115 | for i, (idx, prob) in enumerate(zip(top5_idx, top5_prob), 1): |
| 116 | print(f" {i}. {self.classes[idx]:15s} {prob:.2%}") |
| 117 | |
| 118 | def test_class_accuracy(self): |
| 119 | print("\nCalculating per-class accuracy...") |
no test coverage detected