Beispiel #1
0
    def evaluation(self, test_data, test_label):
        scores = []

        if self.D > 0:
            for d, t in test_data:
                score = self.predict(d, t)
                if score > 200:
                    scores.append(1)
                elif score < -200:
                    scores.append(0)
                else:
                    sc = np.exp(score)
                    scores.append(sc / (1 + sc))

        self.scores = scores
        x, y = test_data[:, 0], test_data[:, 1]
        test_data_T = np.column_stack((y, x))

        ndcg = normalized_discounted_cummulative_gain(test_data, test_label,
                                                      np.array(scores))
        ndcg_inv = normalized_discounted_cummulative_gain(
            test_data_T, test_label, np.array(scores))
        prec, rec, thr = precision_recall_curve(test_label, scores)
        aupr_val = auc(rec, prec)
        fpr, tpr, thr = roc_curve(test_label, scores)
        auc_val = auc(fpr, tpr)

        return aupr_val, auc_val, ndcg, ndcg_inv
Beispiel #2
0
 def evaluation(self, test_data, test_label,scores):       
     
     x, y = test_data[:, 0], test_data[:, 1]
     test_data_T = np.column_stack((y,x))
     
     ndcg = normalized_discounted_cummulative_gain(test_data, np.array(test_label), np.array(scores))
     ndcg_inv = normalized_discounted_cummulative_gain(test_data_T, np.array(test_label), np.array(scores))
     prec, rec, thr = precision_recall_curve(test_label, scores)
     aupr_val = auc(rec, prec)
     fpr, tpr, thr = roc_curve(test_label, scores)
     auc_val = auc(fpr, tpr)
     
     return aupr_val, auc_val, ndcg, ndcg_inv
Beispiel #3
0
 def evaluation(self, test_data, test_label):
     scores = self.predictR[test_data[:, 0], test_data[:, 1]]
     self.scores = scores  
     x, y = test_data[:, 0], test_data[:, 1]
     test_data_T = np.column_stack((y,x))
     
     ndcg = normalized_discounted_cummulative_gain(test_data, test_label, np.array(scores))
     ndcg_inv = normalized_discounted_cummulative_gain(test_data_T, test_label, np.array(scores))
     prec, rec, thr = precision_recall_curve(test_label, scores)
     aupr_val = auc(rec, prec)
     fpr, tpr, thr = roc_curve(test_label, scores)
     auc_val = auc(fpr, tpr)
     
     #!!!!we should distinguish here between inverted and not inverted methods nDCGs!!!!
     return aupr_val, auc_val, ndcg, ndcg_inv