Esempio n. 1
0
def make_predictions_and_evaluate_gpu(conf,shot_list,loader,custom_path=None):
    y_prime,y_gold,disruptive = make_predictions_gpu(conf,shot_list,loader,custom_path)
    analyzer = PerformanceAnalyzer(conf=conf)
    roc_area = analyzer.get_roc_area(y_prime,y_gold,disruptive)
    shot_list.set_weights(analyzer.get_shot_difficulty(y_prime,y_gold,disruptive))
    loss = get_loss_from_list(y_prime,y_gold,conf['data']['target'])
    return y_prime,y_gold,disruptive,roc_area,loss
Esempio n. 2
0
def mpi_make_predictions_and_evaluate(conf,shot_list,loader,custom_path=None):
    y_prime,y_gold,disruptive = mpi_make_predictions(conf,shot_list,loader,custom_path)
    analyzer = PerformanceAnalyzer(conf=conf)
    roc_area = analyzer.get_roc_area(y_prime,y_gold,disruptive)
    shot_list.set_weights(analyzer.get_shot_difficulty(y_prime,y_gold,disruptive))
    loss = get_loss_from_list(y_prime,y_gold,conf['data']['target'])
    return y_prime,y_gold,disruptive,roc_area,loss
def make_predictions_and_evaluate_multiple_times(conf,
                                                 shot_list,
                                                 loader,
                                                 times,
                                                 custom_path=None):
    y_prime, y_gold, disruptive = make_predictions(conf, shot_list, loader,
                                                   custom_path)
    areas = []
    losses = []
    for T_min_curr in times:
        # if 'monitor_test' in conf['callbacks'].keys() and
        # conf['callbacks']['monitor_test']:
        conf_curr = deepcopy(conf)
        T_min_warn_orig = conf['data']['T_min_warn']
        conf_curr['data']['T_min_warn'] = T_min_curr
        assert conf['data']['T_min_warn'] == T_min_warn_orig
        analyzer = PerformanceAnalyzer(conf=conf_curr)
        roc_area = analyzer.get_roc_area(y_prime, y_gold, disruptive)
        # shot_list.set_weights(analyzer.get_shot_difficulty(y_prime, y_gold,
        # disruptive))
        loss = get_loss_from_list(y_prime, y_gold, conf['data']['target'])
        areas.append(roc_area)
        losses.append(loss)
    return areas, losses
Esempio n. 4
0
def make_predictions_and_evaluate_gpu(conf, shot_list, loader):
    y_prime, y_gold, disruptive = make_predictions(conf, shot_list, loader)
    analyzer = PerformanceAnalyzer(conf=conf)
    roc_area = analyzer.get_roc_area(y_prime, y_gold, disruptive)
    loss = get_loss_from_list(y_prime, y_gold, conf['data']['target'])
    return y_prime, y_gold, disruptive, roc_area, loss
Esempio n. 5
0
# mode = 'test'
file_num = 0
save_figure = True
pred_ttd = False

T_min_warn = 30  # None #take value from conf #30

verbose = False
if len(sys.argv) == 3:
    results_dir = sys.argv[1]
    num = int(sys.argv[2])
else:
    results_dir = conf['paths']['results_prepath']
    num = int(sys.argv[1])

print("loading results from {}".format(results_dir))
print("Plotting shot {}".format(num))
shots_dir = conf['paths']['processed_prepath']

analyzer = PerformanceAnalyzer(conf=conf,
                               results_dir=results_dir,
                               shots_dir=shots_dir,
                               i=file_num,
                               T_min_warn=T_min_warn,
                               verbose=verbose,
                               pred_ttd=pred_ttd)

analyzer.load_ith_file()
P_thresh_opt = analyzer.compute_tradeoffs_and_print_from_training()
analyzer.plot_individual_shot(P_thresh_opt, num)
# dt = conf['data']['dt']
# T_max_warn = int(round(conf['data']['T_warning']/dt))
# T_min_warn = conf['data']['T_min_warn']
# T_min_warn = int(round(conf['data']['T_min_warn']/dt))
# if cut_shot_ends:
# 	T_max_warn = T_max_warn-T_min_warn
# 	T_min_warn = 0
T_min_warn = 30  # None #take value from conf #30

verbose = False
assert(sys.argv > 1)
results_dirs = sys.argv[1:]
shots_dir = conf['paths']['processed_prepath']

analyzers = [PerformanceAnalyzer(conf=conf, results_dir=results_dir,
                                 shots_dir=shots_dir, i=file_num,
                                 T_min_warn=T_min_warn,
                                 verbose=verbose, pred_ttd=pred_ttd)
             for results_dir in results_dirs]

for analyzer in analyzers:
    analyzer.load_ith_file()
    analyzer.verbose = False

P_threshs = [analyzer.compute_tradeoffs_and_print_from_training()
             for analyzer in analyzers]

print('Test ROC:')
for analyzer in analyzers:
    print(analyzer.get_roc_area_by_mode('test'))
# P_thresh_opt = 0.566#0.566#0.92#
# analyzer.compute_tradeoffs_and_print_from_training()