Source code for wbia.expt.experiment_printres

# -*- coding: utf-8 -*-
"""
displays results from harness

TODO: save a testres variable so reloading and regenration becomes easier.
"""
import logging
import numpy as np
import utool as ut

print, rrr, profile = ut.inject2(__name__)
logger = logging.getLogger('wbia')


[docs]def get_diffranks(rank_mat, qaids): """Find rows which scored differently over the various configs FIXME: duplicated """ isdiff_flags = [not np.all(row == row[0]) for row in rank_mat] diff_aids = ut.compress(qaids, isdiff_flags) diff_rank = rank_mat.compress(isdiff_flags, axis=0) diff_qxs = np.where(isdiff_flags)[0] return diff_aids, diff_rank, diff_qxs
[docs]def get_diffmat_str(rank_mat, qaids, nConfig): from itertools import chain diff_aids, diff_rank, diff_qxs = get_diffranks(rank_mat, qaids) # Find columns that ore strictly better than other columns # def find_strictly_better_columns(diff_rank): # colmat = diff_rank.T # pairwise_betterness_ranks = np.array([np.sum(col <= colmat, axis=1) / len(col) for col in colmat], dtype=np.float).T diff_mat = np.vstack((diff_aids, diff_rank.T)).T col_lbls = list(chain(['qaid'], map(lambda x: 'cfg%d_rank' % x, range(nConfig)))) col_type = list(chain([int], [int] * nConfig)) header = 'diffmat' diff_matstr = ut.numpy_to_csv(diff_mat, col_lbls, header, col_type) return diff_matstr
[docs]def rankscore_str(thresh, nLess, total, withlbl=True): # helper to print rank scores of configs percent = 100 * nLess / total fmtsf = '%' + str(ut.num2_sigfig(total)) + 'd' if withlbl: fmtstr = ( ':#ranks < %d = ' + fmtsf + '/%d = (%.1f%%) (err=' + fmtsf + '/' + str(total) + ')' ) rankscore_str = fmtstr % (thresh, nLess, total, percent, (total - nLess)) else: fmtstr = fmtsf + '/%d = (%.1f%%) (err=' + fmtsf + '/' + str(total) + ')' rankscore_str = fmtstr % (nLess, total, percent, (total - nLess)) return rankscore_str