Skip to content

Commit

Permalink
Only check if prediction confidence isn't null
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyborger1 committed Mar 5, 2024
1 parent 09c72a7 commit d2b3d7c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/com/botdetector/http/BotDetectorClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,15 @@ public void onResponse(Call call, Response response)
{
Prediction p = processResponse(gson, response, Prediction.class);
// Sanity check for if the primary label does not appear in the breakdown
if (p != null && p.getPredictionBreakdown() != null && !p.getPredictionBreakdown().isEmpty())
if (p != null
&& p.getConfidence() != null // Some 'debug' labels such as 'Stats_Too_Low' will have null confidence, ignore these!
&& p.getPredictionBreakdown() != null
&& !p.getPredictionBreakdown().isEmpty()
&& p.getPredictionBreakdown().keySet().stream().noneMatch(x -> p.getPredictionLabel().equalsIgnoreCase(x)))
{
if (p.getPredictionBreakdown().keySet().stream()
.noneMatch(x -> p.getPredictionLabel().equalsIgnoreCase(x)))
{
p.getPredictionBreakdown().put(p.getPredictionLabel(), p.getConfidence());
log.warn(String.format("Primary prediction label missing from breakdown! Added missing label. (pl:'%s', id:'%d', lb:'%s', cf:'%.4f')",
p.getPlayerName(), p.getPlayerId(), p.getPredictionLabel(), p.getConfidence()));
}
p.getPredictionBreakdown().put(p.getPredictionLabel(), p.getConfidence());
log.warn(String.format("Primary prediction label missing from breakdown! Added missing label. (pl:'%s', id:'%d', lb:'%s', cf:'%.4f')",
p.getPlayerName(), p.getPlayerId(), p.getPredictionLabel(), p.getConfidence()));
}
future.complete(p);
}
Expand Down

0 comments on commit d2b3d7c

Please sign in to comment.