def get_performance_wrap(run_path, det_file, beta=2):

    config = loadfile(os.path.join(run_path, 'config.yaml'))
    config = proc_config(config)
    detections_test_file = os.path.join(run_path, det_file)

    thresh, fppi, miss_rate, recall, precision = \
        get_perform_measures_from_file(
            os.path.join(config['data_path'], config['detect_test_set']),
            detections_test_file,
            overlap=config['overlap_threshold'])

    fscore = get_fscore(recall, precision, beta=beta)
    precision_recall_auc = metrics.auc(
        recall, precision, reorder=True)

    logavg_miss_rate = get_avg_miss_rate(fppi, miss_rate)

    return dict(
        precision_recall_auc=precision_recall_auc,
        logavg_miss_rate=logavg_miss_rate,
        thresh=thresh,
        fppi=fppi,
        miss_rate=miss_rate,
        recall=recall,
        precision=precision,
        fscore=fscore,
    )
def test_on_patches():

    config = loadfile('config.yaml')
    config['flag_debug'] = True
    config = proc_config(config)


    X_train_init, y_train_init, X_valid_init, y_valid_init =  \
        load_initial_data_wrap(config)

    train_img_list = recover_image_from_vector(X_train_init)
    valid_img_list = recover_image_from_vector(X_valid_init)

    bowsvm = BowSvm(kernel='linear', C=100.)

    time_start = time.time()
    print 'training...'
    bowsvm.fit(train_img_list, y_train_init)
    print time.time() - time_start

    time_start = time.time()
    labels_pred_train = bowsvm.predict(train_img_list)
    labels_pred_valid = bowsvm.predict(valid_img_list)
    print time.time() - time_start
    print accuracy_score(y_train_init, labels_pred_train)
    print accuracy_score(y_valid_init, labels_pred_valid)
示例#3
0
def get_image_level_performance_wrap(run_path, det_file, overlap=0.5, beta=2.):
    config = loadfile(os.path.join(run_path, 'config.yaml'))
    config = proc_config(config)
    detections_test_file = os.path.join(run_path, det_file)

    return get_image_level_performance_from_file(os.path.join(
        config['data_path'], config['detect_test_set']),
                                                 detections_test_file,
                                                 overlap=overlap,
                                                 beta=beta)
    x_cat = np.concatenate([
        np.concatenate(x_pad[ind * num_row:(ind + 1) * num_row], axis=0)
        for ind in range(num_col)
    ],
                           axis=1)

    return x_cat


path = '/mnt/data/wding/tmp/bugs/bug_run_2015-04-14_20-58-36_39_single/misdetects0.pkl'

_, x_new_neg = loadfile(path)

config = loadfile('config.yaml')
config['flag_debug'] = True
config = proc_config(config)
config['dist_trans_list'] = (-5, 0, 5)
config['write_path'] = \
    '/mnt/data/wding/tmp/bugs/bug_run_2015-04-14_20-58-36_39_single'
x, y, _, _ = load_initial_data_wrap(config)
# x_new_neg, _ = load_misclf_data_wrap(config, ind_round=1, data_set='train')
_, x_new_neg = loadfile(path)
x_new_neg = np.array(x_new_neg) / 255.

x_reshaped = np.rollaxis(x.reshape((-1, 3, 28, 28)), 1, 4) / 255.

x_pos = x_reshaped[y.astype(bool)]
num_unique = x_pos.shape[0] / 72

ind_unique = 1
indices = []