コード例 #1
0
ファイル: evalmetrics.py プロジェクト: wy51r/recsys
    def __init__(self, dataset, test, N=20, I=300):
        """ Input: 
            -> dataset <list> : all data in list form.
            -> N <Integer> : Length of the recommendation list.
            -> I <Integer> : Number of Pseudo-items. The assumption is that
               all of these items are not relevant for our user[1].
            -> test  <<user => {movie => rating}>,
                     <movie => {user => rating}>>: Contains test dbs. 


        [1]: Cremonesi, P., Milano, P. & Turrin, R., 2010. Performance of
        Recommender Algorithms on Top-N Recommendation Tasks. Methodology, 
        p.39. Available at: http://portal.acm.org/citation.cfm?id=
        1864708.1864721
        
        """

        self.test_db, self.test_idb = test
        self.N = N
        self.db, self.idb, movies = dataload.read_data_to_hash(dataset)
        self.I = I

        self.n_hit = 0
        self.n_miss = 0
        self.recall = 0
        self.precision = 0

        print self
コード例 #2
0
ファイル: evalmetrics.py プロジェクト: HuXiLiFeng/recsys
    def __init__(self, dataset, test, N=20, I=300):
        
        """ Input: 
            -> dataset <list> : all data in list form.
            -> N <Integer> : Length of the recommendation list.
            -> I <Integer> : Number of Pseudo-items. The assumption is that
               all of these items are not relevant for our user[1].
            -> test  <<user => {movie => rating}>,
                     <movie => {user => rating}>>: Contains test dbs. 


        [1]: Cremonesi, P., Milano, P. & Turrin, R., 2010. Performance of
        Recommender Algorithms on Top-N Recommendation Tasks. Methodology, 
        p.39. Available at: http://portal.acm.org/citation.cfm?id=
        1864708.1864721
        
        """

        self.test_db, self.test_idb = test
        self.N = N
        self.db, self.idb, movies = dataload.read_data_to_hash(dataset)
        self.I = I
        
        self.n_hit = 0
        self.n_miss = 0
        self.recall = 0
        self.precision = 0

        print self
コード例 #3
0
ファイル: evaluate.py プロジェクト: wy51r/recsys
    def createRecSystem(self):

        db, idb, movies = dataload.read_data_to_hash(self.trainset)

        self.rec = KNeighborRegressor(db,
                                      idb,
                                      k=self.k,
                                      sim_method=self.sim_method,
                                      rec_type=self.rec_type)
コード例 #4
0
ファイル: evaluate.py プロジェクト: wy51r/recsys
 def evaluate(self, k=1, N=20, I=300):
     """
         Input:
             -> k: Number of item(s) which are/is the user appreciates
                most. (Only for Precision & Recall)
     """
     test_db, test_idb, m = dataload.read_data_to_hash(self.testset)
     if self.rec_type == 'ib':
         test_db, test_idb = test_idb, test_db
     if self.eval_metric == 'mae':
         return self.__calc_mae(test_db)
     elif self.eval_metric == 'pr':  # precision & Recall
         return self.__calc_pr((test_db, test_idb), k, N, I)
     else:
         stderr.write("There is no such evaluation metric you can use")
         exit(1)
コード例 #5
0
ファイル: evaluate.py プロジェクト: HuXiLiFeng/recsys
    def evaluate(self, k=1, N=20, I=300):

        """
            Input:
                -> k: Number of item(s) which are/is the user appreciates
                   most. (Only for Precision & Recall)
        """
        test_db, test_idb, m = dataload.read_data_to_hash(self.testset)
        if self.rec_type == 'ib':
            test_db, test_idb = test_idb, test_db
        if self.eval_metric == 'mae':
            return self.__calc_mae(test_db)
        elif self.eval_metric == 'pr': # precision & Recall
            return self.__calc_pr((test_db, test_idb), k, N, I)
        else:
            stderr.write("There is no such evaluation metric you can use")
            exit(1) 
コード例 #6
0
ファイル: evaluate.py プロジェクト: HuXiLiFeng/recsys
    def createRecSystem(self):
        
        db, idb, movies = dataload.read_data_to_hash(self.trainset)

        self.rec = KNeighborRegressor(db, idb, k=self.k, 
                    sim_method=self.sim_method, rec_type=self.rec_type)