public static void evaluate ( final int nFolds , final String splitPath , final String recPath ) { double ndcgRes = 0.0 ; double precisionRes = 0.0 ; double rmseRes = 0.0 ; for ( int i = 0 ; i < nFolds ; i ++ ) { File testFile = new File ( splitPath + "test_" + i + ".csv" ) ; File recFile = new File ( recPath + "recs_" + i + ".csv" ) ; DataModelIF < Long , Long > testModel = null ; DataModelIF < Long , Long > recModel = null ; try { testModel = new SimpleParser ( ) . parseData ( testFile ) ; recModel = new SimpleParser ( ) . parseData ( recFile ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } NDCG < Long , Long > ndcg = new NDCG <> ( recModel , testModel , new int [ ] { AT } ) ; ndcg . compute ( ) ; ndcgRes += ndcg . getValueAt ( AT ) ; RMSE < Long , Long > rmse = new RMSE <> ( recModel , testModel ) ; rmse . compute ( ) ; rmseRes += rmse . getValue ( ) ; Precision < Long , Long > precision = new Precision <> ( recModel , testModel , REL_TH , new int [ ] { AT } ) ; precision . compute ( ) ; precisionRes += precision . getValueAt ( AT ) ; } System . out . println ( "NDCG@" + AT + ": " + ndcgRes / nFolds ) ; System . out . println ( "RMSE: " + rmseRes / nFolds ) ; System . out . println ( "P@" + AT + ": " + precisionRes / nFolds ) ; }
Evaluates the recommendations generated in previous steps .