Spaces:
Sleeping
Sleeping
Upload backend/chatbot/tests/test_intent_training.py with huggingface_hub
Browse files
backend/chatbot/tests/test_intent_training.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import unittest
|
| 4 |
+
|
| 5 |
+
from hue_portal.chatbot.training import train_intent
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class IntentTrainingTestCase(unittest.TestCase):
|
| 9 |
+
def test_train_pipeline_produces_artifacts(self):
|
| 10 |
+
model_path, metrics_path, metrics = train_intent.train(train_intent.DEFAULT_DATASET, test_size=0.3, random_state=123)
|
| 11 |
+
|
| 12 |
+
self.assertTrue(model_path.exists(), "Model artifact should be created")
|
| 13 |
+
self.assertTrue(metrics_path.exists(), "Metrics file should be created")
|
| 14 |
+
|
| 15 |
+
payload = json.loads(metrics_path.read_text(encoding="utf-8"))
|
| 16 |
+
self.assertIn("accuracy", payload)
|
| 17 |
+
self.assertGreaterEqual(payload["accuracy"], 0.0)
|
| 18 |
+
self.assertLessEqual(payload["accuracy"], 1.0)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
if __name__ == "__main__":
|
| 22 |
+
unittest.main()
|