From 49da7cfdb06f3185c969f3f4bc22896d11fe48eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Fri, 27 Jul 2018 17:04:29 -0700 Subject: [PATCH] Display cred explorer scores as -Log(score) (#535) @wchargin suggested displaying scores this way. This way, lowest scores are best, and higher scores are worse. This is a little counterintuitive, but maybe less counterintuitive than the current approach, which arbitrarily adds 10 to scores to keep them non-negative, and results in an arbitrary crossing point where scores become negative without any particular significance. Test plan: Travis, and manual inspection of the frontend. --- src/app/credExplorer/PagerankTable.js | 3 +-- src/app/credExplorer/PagerankTable.test.js | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/app/credExplorer/PagerankTable.js b/src/app/credExplorer/PagerankTable.js index 8a2bb8b..8d936f8 100644 --- a/src/app/credExplorer/PagerankTable.js +++ b/src/app/credExplorer/PagerankTable.js @@ -67,8 +67,7 @@ function edgeVerb( } function scoreDisplay(probability: number) { - const modifiedLogScore = Math.log(probability) + 10; - return modifiedLogScore.toFixed(2); + return (-1 * Math.log(probability)).toFixed(2); } type SharedProps = {| diff --git a/src/app/credExplorer/PagerankTable.test.js b/src/app/credExplorer/PagerankTable.test.js index 275f065..a936007 100644 --- a/src/app/credExplorer/PagerankTable.test.js +++ b/src/app/credExplorer/PagerankTable.test.js @@ -378,7 +378,7 @@ describe("app/credExplorer/PagerankTable", () => { it("renders a score column with the node's log-score", async () => { const {element, sharedProps, node} = await setup(); const {score: rawScore} = NullUtil.get(sharedProps.pnd.get(node)); - const expectedScore = (Math.log(rawScore) + 10).toFixed(2); + const expectedScore = (-Math.log(rawScore)).toFixed(2); const contributionColumn = COLUMNS().indexOf("Score"); expect(contributionColumn).not.toEqual(-1); expect( @@ -528,9 +528,7 @@ describe("app/credExplorer/PagerankTable", () => { }); it("renders a score column with the source's log-score", async () => { const {element, contribution} = await setup(); - const expectedScore = (Math.log(contribution.sourceScore) + 10).toFixed( - 2 - ); + const expectedScore = (-Math.log(contribution.sourceScore)).toFixed(2); const contributionColumn = COLUMNS().indexOf("Score"); expect(contributionColumn).not.toEqual(-1); expect(