From fb31f850e75d5746f1810c56bc86464a3d1c7c82 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Tue, 7 Sep 2021 10:46:27 -0500 Subject: [PATCH] int -> float --- .../mooc/nonpers/assoc/BasicAssociationModelProvider.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nonpers-assignment/src/main/java/org/lenskit/mooc/nonpers/assoc/BasicAssociationModelProvider.java b/nonpers-assignment/src/main/java/org/lenskit/mooc/nonpers/assoc/BasicAssociationModelProvider.java index 415941b..190eda7 100644 --- a/nonpers-assignment/src/main/java/org/lenskit/mooc/nonpers/assoc/BasicAssociationModelProvider.java +++ b/nonpers-assignment/src/main/java/org/lenskit/mooc/nonpers/assoc/BasicAssociationModelProvider.java @@ -62,6 +62,7 @@ public class BasicAssociationModelProvider implements Provider for (Long2ObjectMap.Entry xEntry: itemUsers.long2ObjectEntrySet()) { long xId = xEntry.getLongKey(); LongSortedSet xUsers = xEntry.getValue(); + HashSet xSet = new HashSet(xUsers); // set up a map to hold the scores for each 'y' item for this 'x' Long2DoubleMap itemScores = new Long2DoubleOpenHashMap(); @@ -72,9 +73,9 @@ public class BasicAssociationModelProvider implements Provider LongSortedSet yUsers = yEntry.getValue(); // TODO Compute P(Y & X) / P(X) and store in itemScores - HashSet ySet = new HashSet(yUsers), xSet = new HashSet(xUsers); + HashSet ySet = new HashSet(yUsers); ySet.retainAll(xSet); - double p = ySet.size() / xSet.size(); + double p = 1.0 * ySet.size() / xUsers.size(); itemScores.put(yId, p); }