Source code for ibeis.expt.experiment_printres

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

TODO: save a testres variable so reloading and regenration becomes easier.
"""
from __future__ import absolute_import, division, print_function, unicode_literals
import numpy as np
import six
import utool as ut
#from ibeis.other import ibsfuncs
#from ibeis.expt import experiment_drawing
from six.moves import map, range, input  # NOQA
import vtool as vt
print, rrr, profile = ut.inject2(__name__, '[expt_printres]')


[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
@profile
[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 #def wrap_cfgstr(cfgstr): # # REGEX to locate _XXXX( # import re # cfg_regex = r'_[A-Z][A-Z]*\(' # cfgstrmarker_list = re.findall(cfg_regex, cfgstr) # cfgstrconfig_list = re.split(cfg_regex, cfgstr) # args = [cfgstrconfig_list, cfgstrmarker_list] # interleave_iter = ut.interleave(args) # new_cfgstr_list = [] # total_len = 0 # prefix_str = '' # # If unbalanced there is a prefix before a marker # if len(cfgstrmarker_list) < len(cfgstrconfig_list): # frag = interleave_iter.next() # new_cfgstr_list += [frag] # total_len = len(frag) # prefix_str = ' ' * len(frag) # # Iterate through markers and config strings # while True: # try: # marker_str = interleave_iter.next() # config_str = interleave_iter.next() # frag = marker_str + config_str # except StopIteration: # break # total_len += len(frag) # new_cfgstr_list += [frag] # # Go to newline if past 80 chars # if total_len > 80: # total_len = 0 # new_cfgstr_list += ['\n' + prefix_str] # wrapped_cfgstr = ''.join(new_cfgstr_list) # return wrapped_cfgstr #def format_cfgstr_list(cfgstr_list): # indented_list = ut.indent_list(' ', cfgstr_list) # wrapped_list = list(map(wrap_cfgstr, indented_list)) # return ut.joins('\n', wrapped_list)
if __name__ == '__main__': """ CommandLine: python -m ibeis.expt.experiment_printres python -m ibeis.expt.experiment_printres --allexamples python -m ibeis.expt.experiment_printres --allexamples --noface --nosrc """ import multiprocessing multiprocessing.freeze_support() # for win32 import utool as ut # NOQA ut.doctest_funcs()