idf / FaceReader

Face Recognition, CZ4041 Machine Learning, Spring 2015
http://git.io/vJnox
MIT License
5 stars 3 forks source link

Validation Result no TN FN #2

Closed idf closed 9 years ago

idf commented 9 years ago

It is not possible to calculate the true_negatives and false_negatives with the way the predicitions are generated and data is prepared.

idf commented 9 years ago

Temporary fix

    def evaluate(self, testIdX, predictions, y, threshold):
        r = TFPN()
        for cls in np.unique(y):
            # binary classification
            for j in testIdX:
                prediction, info = predictions[j]
                sims = info['similarities']
                score = np.sum(sims)/float(sims.size)
                if prediction==cls and score>threshold:  # positive
                    if cls==y[j]:
                        r.TP += 1
                    else:
                        r.FP += 1
                else:  # negatives  # TODO
                    if cls==y[j]:
                        r.FN += 1
                    else:
                        r.TN += 1
        # TODO then take average
        # r.rates /= len(np.unique(y))
        return r