threshold=0.5, window=20, num_cols=8, figsize=(30, 5)) outfile = os.path.join(save_path, name + '.pdf') fig.savefig(outfile, format='pdf', dpi=200, bbox_inches='tight') plt.close() # clip filters about motif to reduce false-positive Tomtom matches W_clipped = utils.clip_filters(W, threshold=0.5, pad=3) output_file = os.path.join(save_path, name + '.meme') utils.meme_generate(W_clipped, output_file) # predict test sequences and calculate performance metrics predictions = model.predict(x_test) mean_vals, std_vals = metrics.calculate_metrics( y_test, predictions, 'binary') trial_roc_mean.append(mean_vals[1]) trial_roc_std.append(std_vals[1]) trial_pr_mean.append(mean_vals[2]) trial_pr_std.append(std_vals[2]) f.write( "%s\t%.3f+/-%.3f\t%.3f+/-%.3f\n" % (base_name, np.mean(trial_roc_mean), np.std(trial_roc_mean), np.mean(trial_pr_mean), np.std(trial_pr_mean)))
def update(self, loss, prediction, label): scores = metrics.calculate_metrics(label, prediction, self.objective) self.add_loss(loss) self.add_metrics(scores)