Do you want to do evaluation or you want to use the recommender. With the above code you are evaluating the efficiency of the algorithm (similarity measure together with the recommender algorithm) against your data set. If you want to use the results the recommender is producing you can use the following simple code:
class RecommenderExample {
public static void main(String[] args) throws Exception {
DataModel model = new FileDataModel (new File("u1.base"));
UserSimilarity similarity = new TanimotoCoefficientSimilarity(model);
UserNeighborhood neighborhood = new NearestNUserNeighborhood(50, similarity, model);
Recommender recommender = new GenericUserBasedRecommender (model, neighborhood, similarity);
List<RecommendedItem> recommendations = recommender.recommend(1, 1);
//Print the results
for (RecommendedItem recommendation : recommendations) {
System.out.println(recommendation);
}
}
}
In any case you need evaluation to choose the best algorithm, but at the end if you want to recommend items to the user you can use similar code like this one.
You can find more about Mahout in the book Mahout in Action.