parameters = load_input_output_file_parameters(parameters,opts) if "ensemble" not in parameters: print("Error: ensemble file is required") exit() if "--ensemble_size" not in opts: print("Error: must enter an --ensemble_size") exit() output_file = "new_ensemble_list.txt" if parameters["output_prefix"]: output_file = parameters["output_prefix"] + "_ensemble_list.txt" num = int(opts["--ensemble_size"]) dataSet = deepMirCut.readDataset(parameters["validation_file"],parameters) new_dataSet = deepMirCut.dropLongSequences(dataSet,parameters) X_test,y_test = deepMirCut.prepareData(new_dataSet,parameters) members = [] for i in range(0,len(parameters["ensemble"])): print("loading model %d: %s\n"%(i, parameters["ensemble"][i])) members.append(load_model(parameters["ensemble"][i], custom_objects={'prox':avg_proximity_metric()})) test_pred = [] macro_f1_scores = [] for i in range(0,len(members)): model = members[i] test_pred.append(model.predict(X_test, verbose=parameters["verbose"])) perf = get_classification_metrics(y_test,test_pred[i],parameters) macro_f1_scores.append(sum([perf[c]["fscore"] for c in ["DR5","DC5","DC3","DR3"]]) / 4) print(i,macro_f1_scores[i]) f = open(output_file,"w")
print(err) print_usage() exit() if '--help' in opts: print_usage() exit() parameters = deepMirCut.load_parameters(opts) parameters = load_input_output_file_parameters(parameters, opts) predictions_outputFile = parameters[ "output_prefix"] + "_predicted_cutsites.txt" inputSet = read_predict_set(input_file, parameters) new_inputSet = deepMirCut.dropLongSequences(inputSet, parameters) X_vl, _ = deepMirCut.prepareData(new_inputSet, parameters) if "ensemble" in parameters: predictions = [] for i in range(0, len(parameters["ensemble"])): print("loading model %d: %s\n" % (i, parameters["ensemble"][i])) model = load_model(parameters["ensemble"][i], custom_objects={'prox': avg_proximity_metric()}) predictions.append( model.predict(X_vl, verbose=parameters["verbose"])) predictions_avg = apply_weights(predictions, w=parameters["ensemble_weights"]) print_predictions_output_file(new_inputSet, X_vl, predictions_avg, predictions_outputFile, parameters) if parameters["print_dvs"]: deepMirCut.print_classification_values_file( new_inputSet,
opts = {} opts['--verbose'] = True opts['--epochs'] = 20 opts['--patience'] = 3 opts['--use_embedding_layer'] = "True" opts['--use_crf_layer'] = "False" opts['--input_setting'] = '1' #USE_SEQ_FOLD dmc_parameters = deepMirCut.load_parameters(opts) dmc_parameters['train_file'] = sys.argv[1] dmc_parameters['validation_file'] = sys.argv[2] dmc_parameters['batch_size'] = 64 print("input_setting=", dmc_parameters['input_setting']) trainSet = deepMirCut.readDataset(dmc_parameters["train_file"], dmc_parameters) new_trainSet = deepMirCut.dropLongSequences(trainSet, dmc_parameters) X_tr, y_tr = deepMirCut.prepareData(new_trainSet, dmc_parameters) validationSet = deepMirCut.readDataset(dmc_parameters["validation_file"], dmc_parameters) new_validationSet = deepMirCut.dropLongSequences(validationSet, dmc_parameters) X_vl, y_vl = deepMirCut.prepareData(new_validationSet, dmc_parameters) while (trial_step < new_evals): run_trials(pickle_file="tuning_adam_seqOnly.pickle", trials_step=trial_step) new_evals -= trial_step run_trials(pickle_file="tuning_adam_seqOnly.pickle", trials_step=new_evals)
opts["--validation_file"] = validation_file except getopt.GetoptError as err: print(err) print_usage() exit() if '--help' in opts: print_usage() exit() parameters = deepMirCut.load_parameters(opts) parameters = load_input_output_file_parameters(parameters, opts) validationSet = deepMirCut.readDataset(parameters["validation_file"], parameters) new_validationSet = deepMirCut.dropLongSequences(validationSet, parameters) X_vl, y_vl = deepMirCut.prepareData(new_validationSet, parameters) validation_labels = deepMirCut.pred2label(y_vl, parameters) if "ensemble" in parameters: validation_pred = [] for i in range(0, len(parameters["ensemble"])): print("loading model %d: %s\n" % (i, parameters["ensemble"][i])) model = load_model(parameters["ensemble"][i], custom_objects={'prox': avg_proximity_metric()}) validation_pred.append( model.predict(X_vl, verbose=parameters["verbose"])) #model.summary() validation_pred_avg = apply_weights(validation_pred, w=parameters["ensemble_weights"]) pred_labels = deepMirCut.pred2label(validation_pred_avg, parameters) deepMirCut.print_validation_output_file(new_validationSet, X_vl, validation_labels, pred_labels,