Example #1
0
    def print_eval_metrics(self, nmes, show=False):
        def ced_curve(nmes):
            Y = []
            X = np.linspace(0, 10, 50)
            for th in X:
                recall = 1.0 - lmutils.calc_landmark_failure_rate(nmes, th)
                recall *= 1/len(X)
                Y.append(recall)
            return X,Y

        def auc(recalls):
            return np.sum(recalls)

        # for err_scale in np.linspace(0.1, 1, 10):
        for err_scale in [1.0]:
            # print('\nerr_scale', err_scale)
            # print(np.clip(lm_errs_max_all, a_min=0, a_max=10).mean())

            fr = lmutils.calc_landmark_failure_rate(nmes*err_scale)
            X, Y = ced_curve(nmes)

            log.info('NME:   {:>6.3f}'.format(nmes.mean()*err_scale))
            log.info('FR@10: {:>6.3f} ({})'.format(fr*100, np.sum(nmes.mean(axis=1) > 10)))
            log.info('AUC:   {:>6.4f}'.format(auc(Y)))

            if show:
                import matplotlib.pyplot as plt
                fig, axes = plt.subplots(1,2)
                axes[0].plot(X, Y)
                print(nmes.mean(axis=1).shape)
                print(nmes.mean(axis=1).max())
                axes[1].hist(nmes.mean(axis=1), bins=20)
                plt.show()
 def ced_curve(_nmes):
     y = []
     x = np.linspace(0, 10, 50)
     for th in x:
         recall = 1.0 - lmutils.calc_landmark_failure_rate(_nmes, th)
         recall *= 1 / len(x)
         y.append(recall)
     return x, y
Example #3
0
 def ced_curve(nmes):
     Y = []
     X = np.linspace(0, 10, 50)
     for th in X:
         recall = 1.0 - lmutils.calc_landmark_failure_rate(nmes, th)
         recall *= 1/len(X)
         Y.append(recall)
     return X,Y
    def print_eval_metrics(nmes, show=False):
        def ced_curve(_nmes):
            y = []
            x = np.linspace(0, 10, 50)
            for th in x:
                recall = 1.0 - lmutils.calc_landmark_failure_rate(_nmes, th)
                recall *= 1 / len(x)
                y.append(recall)
            return x, y

        def auc(recalls):
            return np.sum(recalls)

        # for err_scale in np.linspace(0.1, 1, 10):
        for err_scale in [1.0]:
            # print('\nerr_scale', err_scale)
            # print(np.clip(lm_errs_max_all, a_min=0, a_max=10).mean())

            fr = lmutils.calc_landmark_failure_rate(nmes * err_scale)
            X, Y = ced_curve(nmes)

            log.info("NME:   {:>6.3f}".format(nmes.mean() * err_scale))
            log.info("FR@10: {:>6.3f} ({})".format(
                fr * 100, np.sum(nmes.mean(axis=1) > 10)))
            log.info("AUC:   {:>6.4f}".format(auc(Y)))
            # log.info('NME:   {nme:>6.3f}, FR@10: {fr:>6.3f} ({fc}), AUC:   {auc:>6.4f}'.format(
            #     nme=nmes.mean()*err_scale,
            #     fr=fr*100,
            #     fc=np.sum(nmes.mean(axis=1) > 10),
            #     auc=auc(Y)))

            if show:
                import matplotlib.pyplot as plt

                fig, axes = plt.subplots(1, 2)
                axes[0].plot(X, Y)
                axes[1].hist(nmes.mean(axis=1), bins=20)
                plt.show()