Skip to content

fix(api): use zero confidence fallback on prediction error#236

Merged
Userunknown84 merged 1 commit into
Userunknown84:mainfrom
devprashant19:fix/random-confidence-score
Jun 24, 2026
Merged

fix(api): use zero confidence fallback on prediction error#236
Userunknown84 merged 1 commit into
Userunknown84:mainfrom
devprashant19:fix/random-confidence-score

Conversation

@devprashant19

Copy link
Copy Markdown
Contributor

Description

This PR fixes a bug in the /predict endpoint (backend/api.py) where the confidence score calculation silently swallowed exceptions and returned a random, hardcoded fallback percentage between 65% and 99%. This misled users by presenting a fake confidence level whenever the underlying model's predict_proba or decision_function threw an error.
Fixes #224

Changes

  • Removed the random.uniform(65, 99) fallback in the except Exception: block around line 205.
  • Set the fallback confidence to a deterministic and safe 0.0 (or None) when an exception occurs, accurately reflecting that the model's confidence could not be computed.

Related Issues

  • Resolves the fake/random confidence score bug.

Type of Change

  • Security fix
  • Bug fix
  • New feature
  • Refactoring

Pre-submission Checklist

  • Verified that exceptions during confidence calculation no longer generate misleading random values.
  • Checked that normal prediction confidence scores are still accurately extracted from the model.

@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@devprashant19 is attempting to deploy a commit to the Aditya Sharma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Userunknown84 Userunknown84 merged commit b6a1770 into Userunknown84:main Jun 24, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Confidence Score Is Silently Replaced with a Random Number (65–99%) When Calculation Fails

2 participants