this.values = new float[numPrefs];
this.cachedEstimates = new double[numPrefs];
index = 0;
log.info("Loading {} preferences into memory", numPrefs);
RunningAverage average = new FullRunningAverage();
for (Preference preference : factorizablePreferences.getPreferences()) {
userIndexes[index] = userIDMapping.get(preference.getUserID());
itemIndexes[index] = itemIDMapping.get(preference.getItemID());
values[index] = preference.getValue();
cachedEstimates[index] = 0;
average.addDatum(preference.getValue());
index++;
if (index % 1000000 == 0) {
log.info("Processed {} preferences", index);
}
}
log.info("Processed {} preferences, done.", index);
double averagePreference = average.getAverage();
log.info("Average preference value is {}", averagePreference);
double prefInterval = factorizablePreferences.getMaxPreference() - factorizablePreferences.getMinPreference();
defaultValue = Math.sqrt((averagePreference - prefInterval * 0.1) / numFeatures);
interval = prefInterval * 0.1 / numFeatures;