print_section("TOOLS: Measure precision and recall of model") print("-data: path to dataset | -store: job_gui id to store curve in GUI "\ "| -store_path: store results locally | -model: stored model to use") #====== Arguments =============================================== is_dataset_path, dataset_path = get_command( '-data', default='/home/olav/Pictures/Mass_roads_alpha') store_gui, job_id = get_command('-store_gui', default='-1') is_store_path, store_path = get_command('-store_path', default='./pr_data.json') is_model, model_path = get_command('-model', default='./results/params.pkl') #============================================================== store = ParamStorage() data = store.load_params(path=model_path) batch_size = data['optimization'].batch_size measurer = PrecisionRecallCurve(dataset_path, data['params'], data['model'], data['dataset']) datapoints = measurer.get_curves_datapoints(batch_size) if store_gui: send_precision_recall_data(datapoints, None, job_id=job_id) else: with open(store_path, 'w') as outfile: json.dump([{"curve": datapoints, "events": []}], outfile) plt.suptitle('Precision and recall') plt.xlabel('Recall') plt.ylabel('Precision')
verify, stage = get_command('-verify', default="0") stage = "stage" + stage is_tradeoff, tradeoff = get_command('-tradeoff', default="0.5") tradeoff = float(tradeoff) #Dataset path. Config used if not supplied is_alt_dataset, alt_dataset = get_command('-dataset') if is_alt_dataset: dataset_path = alt_dataset #============================================================== store = ParamStorage() teacher = store.load_params(path=teacher_location) evaluate = util.create_simple_predictor(teacher['model'], teacher['params']) if not verify: creator = Creator( pr_path, dim=(dataset_params.input_dim, dataset_params.output_dim), preproccessing=dataset_params.use_preprocessing, std=dataset_params.dataset_std, reduce_training=dataset_params.reduce_training, reduce_testing=dataset_params.reduce_testing, reduce_validation=dataset_params.reduce_validation ) creator.load_dataset() data, labels = creator.sample_data(
'-teacher', default=filename_params.curriculum_teacher) verify, stage = get_command('-verify', default="0") stage = "stage" + stage is_tradeoff, tradeoff = get_command('-tradeoff', default="0.5") tradeoff = float(tradeoff) #Dataset path. Config used if not supplied is_alt_dataset, alt_dataset = get_command('-dataset') if is_alt_dataset: dataset_path = alt_dataset #============================================================== store = ParamStorage() teacher = store.load_params(path=teacher_location) evaluate = util.create_simple_predictor(teacher['model'], teacher['params']) if not verify: creator = Creator(pr_path, dim=(dataset_params.input_dim, dataset_params.output_dim), preproccessing=dataset_params.use_preprocessing, std=dataset_params.dataset_std, reduce_training=dataset_params.reduce_training, reduce_testing=dataset_params.reduce_testing, reduce_validation=dataset_params.reduce_validation) creator.load_dataset() data, labels = creator.sample_data(creator.train, samples,
print_section("TOOLS: Measure precision and recall of model") print( "-data: path to dataset | -store: job_gui id to store curve in GUI " "| -store_path: store results locally | -model: stored model to use" ) # ====== Arguments =============================================== is_dataset_path, dataset_path = get_command("-data", default="/home/olav/Pictures/Mass_roads_alpha") store_gui, job_id = get_command("-store_gui", default="-1") is_store_path, store_path = get_command("-store_path", default="./pr_data.json") is_model, model_path = get_command("-model", default="./results/params.pkl") # ============================================================== store = ParamStorage() data = store.load_params(path=model_path) batch_size = data["optimization"].batch_size measurer = PrecisionRecallCurve(dataset_path, data["params"], data["model"], data["dataset"]) datapoints = measurer.get_curves_datapoints(batch_size) if store_gui: send_precision_recall_data(datapoints, None, job_id=job_id) else: with open(store_path, "w") as outfile: json.dump([{"curve": datapoints, "events": []}], outfile) plt.suptitle("Precision and recall") plt.xlabel("Recall") plt.ylabel("Precision")