codingcoolfun9ed commited on
Commit
7f05762
·
verified ·
1 Parent(s): badce84

fixed some issues w/ the uncertainty

Browse files
Files changed (1) hide show
  1. api/predict.py +8 -8
api/predict.py CHANGED
@@ -175,7 +175,7 @@ def ensemblePredict(text):
175
 
176
  finalPred = 1 if isFake else 0
177
  agreementCount = sum(1 for p in allPreds if p == finalPred)
178
- agreement = float(agreementCount) / len(allPreds)
179
 
180
  del weightedProbs, allPreds
181
  gc.collect()
@@ -264,23 +264,23 @@ def predict_review(text):
264
 
265
  confidence = max(fakeProb, genuineProb)
266
 
 
 
 
267
  if agreement < uncertaintyThreshold:
268
  prediction = "uncertain"
269
  isFakeOutput = None
270
- else:
271
- prediction = "fake" if isFake else "genuine"
272
- isFakeOutput = isFake
273
 
274
  lengthCat = getLengthCategory(cleaned)
275
  tokenCount = len(cleaned.split())
276
 
277
  return {
278
  "prediction": prediction,
279
- "confidence": float(confidence),
280
  "is_fake": isFakeOutput,
281
- "model_agreement": float(agreement),
282
- "fake_probability": float(fakeProb),
283
- "genuine_probability": float(genuineProb),
284
  "length_category": lengthCat,
285
  "token_count": tokenCount
286
  }
 
175
 
176
  finalPred = 1 if isFake else 0
177
  agreementCount = sum(1 for p in allPreds if p == finalPred)
178
+ agreement = agreementCount / len(allPreds)
179
 
180
  del weightedProbs, allPreds
181
  gc.collect()
 
264
 
265
  confidence = max(fakeProb, genuineProb)
266
 
267
+ prediction = "fake" if isFake else "genuine"
268
+ isFakeOutput = isFake
269
+
270
  if agreement < uncertaintyThreshold:
271
  prediction = "uncertain"
272
  isFakeOutput = None
 
 
 
273
 
274
  lengthCat = getLengthCategory(cleaned)
275
  tokenCount = len(cleaned.split())
276
 
277
  return {
278
  "prediction": prediction,
279
+ "confidence": confidence,
280
  "is_fake": isFakeOutput,
281
+ "model_agreement": agreement,
282
+ "fake_probability": fakeProb,
283
+ "genuine_probability": genuineProb,
284
  "length_category": lengthCat,
285
  "token_count": tokenCount
286
  }