Skip to content

Commit

Permalink
Fix confidence bug (#360)
Browse files Browse the repository at this point in the history
This PR fixed a bug when showing confidence in trigger definition. Confidence is usually a non-decreasing function on an interval. But we incorrectly only show confidence when the corresponding anomaly grade is larger than 0.

Testing done:
1. manually tested that the bug is fixed. See attached snapshots.
2. yarn test:jest

Signed-off-by: Kaituo Li <kaituo@amazon.com>
  • Loading branch information
kaituo committed Nov 8, 2022
1 parent 7d074c0 commit 9b74c2a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions server/services/utils/__tests__/adHelpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ describe('helpers', () => {
dataStartTime: 1587929940000,
dataEndTime: 1587930000000,
anomalyGrade: 0,
confidence: 0,
confidence: '0.99',
plotTime: 1587929970000,
},
{
detectorId: 'LNULDnEBdsd5fFw6Wr6N',
dataStartTime: 1587930420000,
dataEndTime: 1587930480000,
anomalyGrade: 0,
confidence: 0,
confidence: '0.99',
plotTime: 1587930450000,
},
],
Expand Down
2 changes: 1 addition & 1 deletion server/services/utils/adHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const anomalyResultMapper = (anomalyResults) => {
? Number.parseFloat(rest.anomalyGrade).toFixed(2)
: 0,
confidence:
rest.anomalyGrade != null && rest.anomalyGrade > 0
rest.confidence != null && rest.confidence > 0
? Number.parseFloat(rest.confidence).toFixed(2)
: 0,
plotTime: rest.dataStartTime + Math.floor((rest.dataEndTime - rest.dataStartTime) / 2),
Expand Down

0 comments on commit 9b74c2a

Please sign in to comment.