Commit e985a03e authored by John Vester's avatar John Vester
Browse files

Include additional reference link, plus clean up code.

parent 61f509df
Pipeline #193307724 passed with stage
in 1 minute and 12 seconds
......@@ -10,6 +10,7 @@ import java.util.Map;
/**
* https://en.wikipedia.org/wiki/Slope_One
* https://www.baeldung.com/java-collaborative-filtering-recommendations
*/
@Slf4j
public final class SlopeOne {
......@@ -17,7 +18,6 @@ public final class SlopeOne {
private static final Map<Artist, Map<Artist, Double>> diff = new HashMap<>();
private static final Map<Artist, Map<Artist, Integer>> freq = new HashMap<>();
private static final Map<Customer, HashMap<Artist, Double>> outputData = new HashMap<>();
public static Map<Customer, HashMap<Artist, Double>> slopeOne(Map<Customer, HashMap<Artist, Double>> data, List<Artist> artists) {
buildDifferencesMatrix(data);
......@@ -61,10 +61,13 @@ public final class SlopeOne {
}
}
log.debug("diff={}", diff);
log.debug("freq={}", freq);
log.debug("data={}", data);
}
private static Map<Customer, HashMap<Artist, Double>> predict(Map<Customer, HashMap<Artist, Double>> data, List<Artist> artists) {
Map<Customer, HashMap<Artist, Double>> outputData = new HashMap<>();
HashMap<Artist, Double> uPred = new HashMap<>();
HashMap<Artist, Integer> uFreq = new HashMap<>();
......@@ -81,7 +84,7 @@ public final class SlopeOne {
double finalValue = predictedValue * freq.get(artistDiff).get(artist);
uPred.put(artistDiff, uPred.get(artistDiff) + finalValue);
uFreq.put(artistDiff, uFreq.get(artistDiff) + freq.get(artistDiff).get(artist));
} catch (NullPointerException e2) {
} catch (NullPointerException e) {
log.warn("A null pointer error was encountered processing artist={} and artistDiff={}", artist, artistDiff);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment