aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclarkohw <66530369+clarkohw@users.noreply.github.com>2021-04-19 20:39:00 -0400
committerGitHub <noreply@github.com>2021-04-19 20:39:00 -0400
commitc1a59efe3ac070bdd6866666bbee5f5b57786777 (patch)
tree6fa47afa0b624eaea0d9ffa24531cad8be35f9d3
parent905460902c06e9df370c91109554ecbbeb730ac7 (diff)
parent01e50d7a0bbab78ffbbf858b03c6b365d2886397 (diff)
Merge branch 'master' into profit-optimization
-rw-r--r--react-frontend/src/components/Visualization.js8
-rw-r--r--src/main/java/edu/brown/cs/student/term/hub/SuspicionRanker.java17
-rw-r--r--src/test/java/edu/brown/cs/student/ProfitCalculationTest.java1
3 files changed, 15 insertions, 11 deletions
diff --git a/react-frontend/src/components/Visualization.js b/react-frontend/src/components/Visualization.js
index 0a0c82a..9a837a1 100644
--- a/react-frontend/src/components/Visualization.js
+++ b/react-frontend/src/components/Visualization.js
@@ -28,18 +28,20 @@ function Visualization(props) {
});
const getNodes = () => {
let nodes = [];
+ const maxScore = props.data[0].suspicionScore;
+ const interval = maxScore / 4;
props.data.forEach(hub => {
if (hub.followers) {
let colorVal = '#f6f7d4';
const score = hub.suspicionScore;
- if(score > 0.8){
+ if(score > (maxScore - interval)){
colorVal = '#d92027'
}
- if(score < 0.8 && score > 0.6){
+ if(score <= (maxScore - interval) && score > (maxScore - interval*2)){
colorVal = '#f37121'
}
- if(score < 0.6 && score > 0.4){
+ if(score <= (maxScore - interval*2) && score > (maxScore - interval*3)){
colorVal = '#fdca40'
}
nodes.push({
diff --git a/src/main/java/edu/brown/cs/student/term/hub/SuspicionRanker.java b/src/main/java/edu/brown/cs/student/term/hub/SuspicionRanker.java
index 9f17569..d37910e 100644
--- a/src/main/java/edu/brown/cs/student/term/hub/SuspicionRanker.java
+++ b/src/main/java/edu/brown/cs/student/term/hub/SuspicionRanker.java
@@ -53,12 +53,12 @@ public class SuspicionRanker {
HubSearch hub = new HubSearch(lm);
Map<Holder, Double> holderToHubScore = hub.runHubSearch(start, end);
-
ProfitCalculation pc = new ProfitCalculation(DatabaseQuerier.getConn(), "",
new Date(start.toEpochMilli()),
new Date(end.toEpochMilli()));
Map<Integer, Double> profitMap = pc.getProfitMap();
+ System.out.println(profitMap);
//if the maps are empty, we abort because we have entirely incomplete data
if(profitMap.isEmpty() || holderToHubScore.isEmpty()){
@@ -66,15 +66,18 @@ public class SuspicionRanker {
}
double profitMax = getMaxOfMap(profitMap);
- /*if all of our values are negative, we need to flip sides so that the
- * biggest loser doesn't end up being the most suspicious person*/
+
+ //if all of our values are negative, we need to flip sides so that the
+ //biggest loser doesn't end up being the most suspicious person*/
if(profitMax <= 0) {
profitMax = Math.abs(getMinOfMap(profitMap));
}
- /*if both the min we found and max we found are 0, then we have
- the special case where all the values are 0, in which case we
- need to avoid dividing by 0*/
+
+ //if both the min we found and max we found are 0, then we have
+ //the special case where all the values are 0, in which case we
+ //need to avoid dividing by 0
+
if(profitMax == 0){
profitMax = 1;
}
@@ -88,9 +91,9 @@ public class SuspicionRanker {
normalizedProfitScore = profitMap.get(guy.getId()) / profitMax;
}
-
double normalizedHubScore = holderToHubScore.get(guy) / hubMax;
double suspicionScore = normalizedHubScore * 0.6 + normalizedProfitScore * 0.4;
+
guy.setSuspicionScore(suspicionScore);
orderedSuspicion.add(guy);
}
diff --git a/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java b/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java
index 68f53fc..0d22109 100644
--- a/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java
+++ b/src/test/java/edu/brown/cs/student/ProfitCalculationTest.java
@@ -139,7 +139,6 @@ public class ProfitCalculationTest {
new ProfitCalculation(DatabaseQuerier.getConn(), "invalidTicker", new Date(1518010558000l),
new Date(1618698807000l));
assertTrue(profitCalculation.getHoldingsList().isEmpty());
-
}
} \ No newline at end of file