fjrmhri commited on
Commit
08d8dbe
·
verified ·
1 Parent(s): c0f2aec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -480,6 +480,7 @@ class BatchPredictRequest(BaseModel):
480
  class PredictResponse(BaseModel):
481
  label: str
482
  score: float
 
483
  probabilities: Dict[str, float]
484
  hoax_probability: float
485
  risk_level: str
@@ -759,10 +760,12 @@ def _build_predict_response(prob_dict: Dict[str, float], original_text: str) ->
759
  p_not_hoax = _extract_not_hoax_probability(prob_dict, p_hoax)
760
  label = _to_canonical_label(p_hoax, teks=original_text)
761
  score = p_hoax if label == "hoax" else p_not_hoax
 
762
  risk_level, risk_explanation = analyze_risk(p_hoax, original_text=original_text)
763
  return PredictResponse(
764
  label=label,
765
- score=_round6(score),
 
766
  probabilities={
767
  "not_hoax": _round6(p_not_hoax),
768
  "hoax": _round6(p_hoax),
@@ -879,7 +882,7 @@ def predict(request: PredictRequest):
879
  prob_list = _predict_proba([original_text], batch_size=1)
880
  if not prob_list:
881
  return PredictResponse(
882
- label="unknown", score=0.0, probabilities={},
883
  hoax_probability=0.0, risk_level="low",
884
  risk_explanation="Teks kosong.",
885
  )
 
480
  class PredictResponse(BaseModel):
481
  label: str
482
  score: float
483
+ confidence: float
484
  probabilities: Dict[str, float]
485
  hoax_probability: float
486
  risk_level: str
 
760
  p_not_hoax = _extract_not_hoax_probability(prob_dict, p_hoax)
761
  label = _to_canonical_label(p_hoax, teks=original_text)
762
  score = p_hoax if label == "hoax" else p_not_hoax
763
+ confidence = _round6(score)
764
  risk_level, risk_explanation = analyze_risk(p_hoax, original_text=original_text)
765
  return PredictResponse(
766
  label=label,
767
+ score=confidence,
768
+ confidence=confidence,
769
  probabilities={
770
  "not_hoax": _round6(p_not_hoax),
771
  "hoax": _round6(p_hoax),
 
882
  prob_list = _predict_proba([original_text], batch_size=1)
883
  if not prob_list:
884
  return PredictResponse(
885
+ label="unknown", score=0.0, confidence=0.0, probabilities={},
886
  hoax_probability=0.0, risk_level="low",
887
  risk_explanation="Teks kosong.",
888
  )