fileOut.close();
MovieLensConverter converter = new MovieLensConverter();
assertEquals(true, converter.convert(strDataPath, null, convertedFileName));
OnlineCF recommender = new OnlineCF();
recommender.setInputPreferences(convertedFileName);
recommender.setIteration(150);
recommender.setMatrixRank(3);
recommender.setSkipCount(1);
recommender.setTaskCount(2);
recommender.setUpdateFunction(MeanAbsError.class);
recommender.setOutputPath(outputFileName);
assertEquals(true, recommender.train());
recommender.load(outputFileName, false);
int correct = 0;
for (Preference<Integer, Integer> test : test_prefs) {
double actual = test.getValue().get();
double estimated = recommender.estimatePreference(test.getUserId(), test.getItemId());
correct += (Math.abs(actual-estimated)<0.5)?1:0;
}
assertEquals(test_prefs.length*0.75, correct, 1);