It is not absolutely necessary to generate recommendation results by estimating preference values. Providing a recommended list from superior to inferior is sufficient for many scenarios without having to include the estimated preference value.
Precision: Ratio of the relevant results in the top results
Full query rate: Percentage of all relevant results included in the top results
Test the previous example:
Package mahout; import Java. io. file; import Org. apache. mahout. cf. taste. common. tasteexception; import Org. apache. mahout. cf. taste. eval. irstatistics; import Org. apache. mahout. cf. taste. eval. recommenderbuilder; import Org. apache. mahout. cf. taste. eval. recommenderirstatsevaluator; import Org. apache. mahout. cf. taste. impl. eval. genericrecommenderirstatsevaluator; import Org. apache. mahout. cf. taste. impl. model. file. filedatamodel; import Org. apache. mahout. cf. taste. impl. neighborhood. nearestnuserneighborhood; import Org. apache. mahout. cf. taste. impl. recommender. genericuserbasedrecommender; import Org. apache. mahout. cf. taste. impl. similarity. pearsoncorrelationsimilarity; import Org. apache. mahout. cf. taste. model. datamodel; import Org. apache. mahout. cf. taste. neighborhood. userneighborhood; import Org. apache. mahout. cf. taste. recommender. recommender; import Org. apache. mahout. cf. taste. similarity. usersimilarity; import Org. apache. mahout. common. randomutils; public class irstatsevalutator {public static void main (string [] ARGs) throws exception {randomutils. usetestseed (); datamodel = new filedatamodel (new file ("Data/intro.csv"); recommenderirstatsevaluator evaluator = new generator (); // builder used to generate recommendation engine, same as the previous example, recommenderbuilder builder = new recommenderbuilder () {public recommender buildrecommender (datamodel model) throws tasteexception {// todo auto-generated method stub // user similarity, multiple methods: usersimilarity similarity = new pearsoncorrelationsimilarity (model); // userneighborhood neighborhood = new neighbor (2, similarity, model); // a recommender return new neighbor (model, model, neighborhood, similarity) ;}}; // estimate the precision and recall ratio of the two recommendation results irstatistics statistics = evaluator. evaluate (builder, null, datamodel, null, 2, genericrecommenderirstatsevaluator. choose_threshold, 1.0); system. out. println ("precision:" + statistics. getprecision (); system. out. println ("query full rate:" + statistics. getrecall ());}}
Output result:
14/08/04 09:46:21 info file. filedatamodel: Creating filedatamodel for file data \ intro.csv 14/08/04 09:46:21 info file. filedatamodel: Reading file info... 14/08/04 09:46:21 info file. filedatamodel: read lines: 2114/08/04 09:46:21 info model. genericdatamodel: processed 5 users14/08/04 09:46:21 info model. genericdatamodel: processed 5 users14/08/04 09:46:21 info model. genericdatamodel: processed 5 users14/08/04 09:46:21 info eval. genericrecommenderirstatsevaluator: evaluated with user 2 in 31ms14/08/04 09:46:21 info eval. genericrecommenderirstatsevaluator: Precision/recall/fall-out/ndcg/Reach: 1.0/1.0/0.0/1.0/1.014 09:46:21 info model. genericdatamodel: processed 5 users14/08/04 09:46:21 info eval. genericrecommenderirstatsevaluator: evaluated with user 4 in 0ms14/08/04 09:46:21 info eval. genericrecommenderirstatsevaluator: Precision/recall/fall-out/ndcg/Reach: 0.75/1.0/0.08333333333333333/1.0/1.0 precision: 0.75 recall: 1.0
File Description: see mahout in action.