File resultFile = new File(System.getProperty("java.io.tmpdir"), "similarities.csv");
if (resultFile.exists()) {
resultFile.delete();
}
DataModel dataModel = new GroupLensDataModel(new File(args[0]));
ItemBasedRecommender recommender = new GenericItemBasedRecommender(dataModel,
new LogLikelihoodSimilarity(dataModel));
BatchItemSimilarities batch = new MultithreadedBatchItemSimilarities(recommender, 5);
int numSimilarities = batch.computeItemSimilarities(Runtime.getRuntime().availableProcessors(), 1,
new FileSimilarItemsWriter(resultFile));
System.out.println("Computed " + numSimilarities + " similarities for " + dataModel.getNumItems() + " items "
+ "and saved them to " + resultFile.getAbsolutePath());
}