From 8455868b041cbb0cbe5310c0b2cdf81d857d7969 Mon Sep 17 00:00:00 2001 From: Alex Garel Date: Wed, 16 Mar 2022 10:43:19 +0100 Subject: [PATCH] feat: disable auto processing of predicted category Sadly our model is not yet good enough to be autonomous --- .../category/neural/category_classifier.py | 2 +- .../category/neural/test_category_classifier.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/robotoff/prediction/category/neural/category_classifier.py b/robotoff/prediction/category/neural/category_classifier.py index 83c3fed272..81199fc8df 100644 --- a/robotoff/prediction/category/neural/category_classifier.py +++ b/robotoff/prediction/category/neural/category_classifier.py @@ -10,7 +10,7 @@ class CategoryPrediction: """CategoryPrediction stores information about a category classification prediction.""" #: threshold on the neural model confidence to automatically apply prediction - NEURAL_CONFIDENCE_THRESHOLD = 0.9 + NEURAL_CONFIDENCE_THRESHOLD = 1.1 # deactivated for now, 1.1 is above 1 def __init__(self, category: str, confidence: float): self.category = category diff --git a/tests/unit/prediction/category/neural/test_category_classifier.py b/tests/unit/prediction/category/neural/test_category_classifier.py index 27b7bbc6e0..e7ca89d303 100644 --- a/tests/unit/prediction/category/neural/test_category_classifier.py +++ b/tests/unit/prediction/category/neural/test_category_classifier.py @@ -12,6 +12,18 @@ def test_category_prediction_to_prediction(): + category_prediction = CategoryPrediction("category", 0.5) + + assert category_prediction.to_prediction() == Prediction( + type=InsightType.category, + value_tag="category", + data={"lang": "xx", "model": "neural", "confidence": 0.5}, + automatic_processing=False, + ) + + +def test_category_prediction_to_prediction_auto(monkeypatch): + monkeypatch.setattr(CategoryPrediction, "NEURAL_CONFIDENCE_THRESHOLD", 0.9) category_prediction = CategoryPrediction("category", 0.9) assert category_prediction.to_prediction() == Prediction(