Python matplotlib.pyplot.xlabel() Examples
The following are 30
code examples of matplotlib.pyplot.xlabel().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.pyplot
, or try the search function
.
Example #1
Source File: __init__.py From EDeN with MIT License | 11 votes |
def plot_confusion_matrix(y_true, y_pred, size=None, normalize=False): """plot_confusion_matrix.""" cm = confusion_matrix(y_true, y_pred) fmt = "%d" if normalize: cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis] fmt = "%.2f" xticklabels = list(sorted(set(y_pred))) yticklabels = list(sorted(set(y_true))) if size is not None: plt.figure(figsize=(size, size)) heatmap(cm, xlabel='Predicted label', ylabel='True label', xticklabels=xticklabels, yticklabels=yticklabels, cmap=plt.cm.Blues, fmt=fmt) if normalize: plt.title("Confusion matrix (norm.)") else: plt.title("Confusion matrix") plt.gca().invert_yaxis()
Example #2
Source File: utils.py From pruning_yolov3 with GNU General Public License v3.0 | 8 votes |
def plot_wh_methods(): # from utils.utils import *; plot_wh_methods() # Compares the two methods for width-height anchor multiplication # https://github.com/ultralytics/yolov3/issues/168 x = np.arange(-4.0, 4.0, .1) ya = np.exp(x) yb = torch.sigmoid(torch.from_numpy(x)).numpy() * 2 fig = plt.figure(figsize=(6, 3), dpi=150) plt.plot(x, ya, '.-', label='yolo method') plt.plot(x, yb ** 2, '.-', label='^2 power method') plt.plot(x, yb ** 2.5, '.-', label='^2.5 power method') plt.xlim(left=-4, right=4) plt.ylim(bottom=0, top=6) plt.xlabel('input') plt.ylabel('output') plt.legend() fig.tight_layout() fig.savefig('comparison.png', dpi=200)
Example #3
Source File: util.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 8 votes |
def compute_roc(y_true, y_pred, plot=False): """ TODO :param y_true: ground truth :param y_pred: predictions :param plot: :return: """ fpr, tpr, _ = roc_curve(y_true, y_pred) auc_score = auc(fpr, tpr) if plot: plt.figure(figsize=(7, 6)) plt.plot(fpr, tpr, color='blue', label='ROC (AUC = %0.4f)' % auc_score) plt.legend(loc='lower right') plt.title("ROC Curve") plt.xlabel("FPR") plt.ylabel("TPR") plt.show() return fpr, tpr, auc_score
Example #4
Source File: __init__.py From EDeN with MIT License | 7 votes |
def plot_roc_curve(y_true, y_score, size=None): """plot_roc_curve.""" false_positive_rate, true_positive_rate, thresholds = roc_curve( y_true, y_score) if size is not None: plt.figure(figsize=(size, size)) plt.axis('equal') plt.plot(false_positive_rate, true_positive_rate, lw=2, color='navy') plt.plot([0, 1], [0, 1], color='gray', lw=1, linestyle='--') plt.xlabel('False positive rate') plt.ylabel('True positive rate') plt.ylim([-0.05, 1.05]) plt.xlim([-0.05, 1.05]) plt.grid() plt.title('Receiver operating characteristic AUC={0:0.2f}'.format( roc_auc_score(y_true, y_score)))
Example #5
Source File: plotFigures.py From fullrmc with GNU Affero General Public License v3.0 | 7 votes |
def plot(PDF, figName, imgpath, show=False, save=True): # plot output = PDF.get_constraint_value() plt.plot(PDF.experimentalDistances,PDF.experimentalPDF, 'ro', label="experimental", markersize=7.5, markevery=1 ) plt.plot(PDF.shellsCenter, output["pdf"], 'k', linewidth=3.0, markevery=25, label="total" ) styleIndex = 0 for key in output: val = output[key] if key in ("pdf_total", "pdf"): continue elif "inter" in key: plt.plot(PDF.shellsCenter, val, STYLE[styleIndex], markevery=5, label=key.split('rdf_inter_')[1] ) styleIndex+=1 plt.legend(frameon=False, ncol=1) # set labels plt.title("$\\chi^{2}=%.6f$"%PDF.squaredDeviations, size=20) plt.xlabel("$r (\AA)$", size=20) plt.ylabel("$g(r)$", size=20) # show plot if save: plt.savefig(figName) if show: plt.show() plt.close()
Example #6
Source File: plot_threshold_vs_success_trans.py From pointnet-registration-framework with MIT License | 7 votes |
def make_plot(files, labels): plt.figure() for file_idx in range(len(files)): rot_err, trans_err = read_csv(files[file_idx]) success_dict = count_success(trans_err) x_range = success_dict.keys() x_range.sort() success = [] for i in x_range: success.append(success_dict[i]) success = np.array(success)/total_cases plt.plot(x_range, success, linewidth=3, label=labels[file_idx]) # plt.scatter(x_range, success, s=50) plt.ylabel('Success Ratio', fontsize=40) plt.xlabel('Threshold for Translation Error', fontsize=40) plt.tick_params(labelsize=40, width=3, length=10) plt.grid(True) plt.ylim(0,1.005) plt.yticks(np.arange(0,1.2,0.2)) plt.xticks(np.arange(0,2.1,0.2)) plt.xlim(0,2) plt.legend(fontsize=30, loc=4)
Example #7
Source File: plot_utils.py From keras-anomaly-detection with MIT License | 6 votes |
def visualize_anomaly(y_true, reconstruction_error, threshold): error_df = pd.DataFrame({'reconstruction_error': reconstruction_error, 'true_class': y_true}) print(error_df.describe()) groups = error_df.groupby('true_class') fig, ax = plt.subplots() for name, group in groups: ax.plot(group.index, group.reconstruction_error, marker='o', ms=3.5, linestyle='', label="Fraud" if name == 1 else "Normal") ax.hlines(threshold, ax.get_xlim()[0], ax.get_xlim()[1], colors="r", zorder=100, label='Threshold') ax.legend() plt.title("Reconstruction error for different classes") plt.ylabel("Reconstruction error") plt.xlabel("Data point index") plt.show()
Example #8
Source File: dataset.py From neural-combinatorial-optimization-rl-tensorflow with MIT License | 6 votes |
def visualize_sampling(self, permutations): max_length = len(permutations[0]) grid = np.zeros([max_length,max_length]) # initialize heatmap grid to 0 transposed_permutations = np.transpose(permutations) for t, cities_t in enumerate(transposed_permutations): # step t, cities chosen at step t city_indices, counts = np.unique(cities_t,return_counts=True,axis=0) for u,v in zip(city_indices, counts): grid[t][u]+=v # update grid with counts from the batch of permutations # plot heatmap fig = plt.figure() rcParams.update({'font.size': 22}) ax = fig.add_subplot(1,1,1) ax.set_aspect('equal') plt.imshow(grid, interpolation='nearest', cmap='gray') plt.colorbar() plt.title('Sampled permutations') plt.ylabel('Time t') plt.xlabel('City i') plt.show()
Example #9
Source File: utils.py From Pytorch-Networks with MIT License | 6 votes |
def plot_result_data(acc_total, acc_val_total, loss_total, losss_val_total, cfg_path, epoch): import matplotlib.pyplot as plt y = range(epoch) plt.plot(y,acc_total,linestyle="-", linewidth=1,label='acc_train') plt.plot(y,acc_val_total,linestyle="-", linewidth=1,label='acc_val') plt.legend(('acc_train', 'acc_val'), loc='upper right') plt.xlabel("Training Epoch") plt.ylabel("Acc on dataset") plt.savefig('{}/acc.png'.format(cfg_path)) plt.cla() plt.plot(y,loss_total,linestyle="-", linewidth=1,label='loss_train') plt.plot(y,losss_val_total,linestyle="-", linewidth=1,label='loss_val') plt.legend(('loss_train', 'loss_val'), loc='upper right') plt.xlabel("Training Epoch") plt.ylabel("Loss on dataset") plt.savefig('{}/loss.png'.format(cfg_path))
Example #10
Source File: analyze_log.py From spinn with MIT License | 6 votes |
def ShowPlots(subplot=False): for log_ind, path in enumerate(FLAGS.path.split(":")): log = Log(path) if subplot: plt.subplot(len(FLAGS.path.split(":")), 1, log_ind + 1) for index in FLAGS.index.split(","): index = int(index) for attr in ["pred_acc", "parse_acc", "total_cost", "xent_cost", "l2_cost", "action_cost"]: if getattr(FLAGS, attr): if "cost" in attr: assert index == 0, "costs only associated with training log" steps, val = zip(*[(l.step, getattr(l, attr)) for l in log.corpus[index] if l.step < FLAGS.iters]) dct = {} for k, v in zip(steps, val): dct[k] = max(v, dct[k]) if k in dct else v steps, val = zip(*sorted(dct.iteritems())) plt.plot(steps, val, label="Log%d:%s-%d" % (log_ind, attr, index)) plt.xlabel("No. of training iteration") plt.ylabel(FLAGS.ylabel) if FLAGS.legend: plt.legend() plt.show()
Example #11
Source File: utils.py From DeepLung with GNU General Public License v3.0 | 6 votes |
def plotnoduledist(annopath): import pandas as pd df = pd.read_csv(annopath+'train/annotations.csv') diameter = df['diameter_mm'].reshape((-1,1)) df = pd.read_csv(annopath+'val/annotations.csv') diameter = np.vstack([df['diameter_mm'].reshape((-1,1)), diameter]) df = pd.read_csv(annopath+'test/annotations.csv') diameter = np.vstack([df['diameter_mm'].reshape((-1,1)), diameter]) fig = plt.figure() plt.hist(diameter, normed=True, bins=50) plt.ylabel('probability') plt.xlabel('Diameters') plt.title('Nodule Diameters Histogram') plt.savefig('nodulediamhist.png')
Example #12
Source File: util.py From neural-fingerprinting with BSD 3-Clause "New" or "Revised" License | 6 votes |
def compute_roc_rfeinman(probs_neg, probs_pos, plot=False): """ TODO :param probs_neg: :param probs_pos: :param plot: :return: """ probs = np.concatenate((probs_neg, probs_pos)) labels = np.concatenate((np.zeros_like(probs_neg), np.ones_like(probs_pos))) fpr, tpr, _ = roc_curve(labels, probs) auc_score = auc(fpr, tpr) if plot: plt.figure(figsize=(7, 6)) plt.plot(fpr, tpr, color='blue', label='ROC (AUC = %0.4f)' % auc_score) plt.legend(loc='lower right') plt.title("ROC Curve") plt.xlabel("FPR") plt.ylabel("TPR") plt.show() return fpr, tpr, auc_score
Example #13
Source File: utils.py From DeepLung with GNU General Public License v3.0 | 6 votes |
def plothistdiameter(trainpath='/media/data1/wentao/tianchi/preprocessing/newtrain/', testpath='/media/data1/wentao/tianchi/preprocessing/newtest/'): diameterlist = [] for fname in os.listdir(trainpath): if fname.endswith('_label.npy'): label = np.load(trainpath+fname) for lidx in xrange(label.shape[0]): diameterlist.append(label[lidx, -1]) for fname in os.listdir(testpath): if fname.endswith('_label.npy'): label = np.load(testpath+fname) for lidx in xrange(label.shape[0]): diameterlist.append(label[lidx, -1]) fig = plt.figure() plt.hist(diameterlist, 50) plt.xlabel('Nodule Diameter') plt.ylabel('# Nodules') plt.title('Nodule Size Histogram') plt.savefig('processnodulesizehist.png')
Example #14
Source File: recall.py From mmdetection with Apache License 2.0 | 6 votes |
def plot_num_recall(recalls, proposal_nums): """Plot Proposal_num-Recalls curve. Args: recalls(ndarray or list): shape (k,) proposal_nums(ndarray or list): same shape as `recalls` """ if isinstance(proposal_nums, np.ndarray): _proposal_nums = proposal_nums.tolist() else: _proposal_nums = proposal_nums if isinstance(recalls, np.ndarray): _recalls = recalls.tolist() else: _recalls = recalls import matplotlib.pyplot as plt f = plt.figure() plt.plot([0] + _proposal_nums, [0] + _recalls) plt.xlabel('Proposal num') plt.ylabel('Recall') plt.axis([0, proposal_nums.max(), 0, 1]) f.show()
Example #15
Source File: recall.py From mmdetection with Apache License 2.0 | 6 votes |
def plot_iou_recall(recalls, iou_thrs): """Plot IoU-Recalls curve. Args: recalls(ndarray or list): shape (k,) iou_thrs(ndarray or list): same shape as `recalls` """ if isinstance(iou_thrs, np.ndarray): _iou_thrs = iou_thrs.tolist() else: _iou_thrs = iou_thrs if isinstance(recalls, np.ndarray): _recalls = recalls.tolist() else: _recalls = recalls import matplotlib.pyplot as plt f = plt.figure() plt.plot(_iou_thrs + [1.0], _recalls + [0.]) plt.xlabel('IoU') plt.ylabel('Recall') plt.axis([iou_thrs.min(), 1, 0, 1]) f.show()
Example #16
Source File: lstm_Attention.py From Bidirectiona-LSTM-for-text-summarization- with MIT License | 6 votes |
def plot_training(history): print(history.history.keys()) # "Accuracy" plt.plot(history.history['acc']) plt.plot(history.history['val_acc']) plt.title('model accuracy') plt.ylabel('accuracy') plt.xlabel('epoch') plt.legend(['train', 'validation'], loc='upper left') plt.show() # "Loss" plt.plot(history.history['loss']) plt.plot(history.history['val_loss']) plt.title('model loss') plt.ylabel('loss') plt.xlabel('epoch') plt.legend(['train', 'validation'], loc='upper left') plt.show()
Example #17
Source File: stress_gui.py From fenics-topopt with MIT License | 6 votes |
def update(self, xPhys, u, title=None): """Plot to screen""" self.im.set_array(-xPhys.reshape((self.nelx, self.nely)).T) stress = self.stress_calculator.calculate_stress(xPhys, u, self.nu) # self.stress_calculator.calculate_fdiff_stress(xPhys, u, self.nu) self.myColorMap.set_norm(colors.Normalize(vmin=0, vmax=max(stress))) stress_rgba = self.myColorMap.to_rgba(stress) stress_rgba[:, :, 3] = xPhys.reshape(-1, 1) self.stress_im.set_array(np.swapaxes( stress_rgba.reshape((self.nelx, self.nely, 4)), 0, 1)) self.fig.canvas.draw() self.fig.canvas.flush_events() if title is not None: plt.title(title) else: plt.xlabel("Max stress = {:.2f}".format(max(stress)[0])) plt.pause(0.01)
Example #18
Source File: classification.py From Kaggler with MIT License | 6 votes |
def plot_roc_curve(y, p): fpr, tpr, _ = roc_curve(y, p) plt.plot(fpr, tpr) plt.plot([0, 1], [0, 1], color='navy', linestyle='--') plt.xlim([0.0, 1.0]) plt.ylim([0.0, 1.05]) plt.xlabel('False Positive Rate') plt.ylabel('True Positive Rate')
Example #19
Source File: stress_gui.py From fenics-topopt with MIT License | 6 votes |
def update(self, xPhys, u, title=None): """Plot to screen""" self.im.set_array(-xPhys.reshape((self.nelx, self.nely)).T) stress = self.stress_calculator.calculate_stress(xPhys, u, self.nu) # self.stress_calculator.calculate_fdiff_stress(xPhys, u, self.nu) self.myColorMap.set_norm(colors.Normalize(vmin=0, vmax=max(stress))) stress_rgba = self.myColorMap.to_rgba(stress) stress_rgba[:, :, 3] = xPhys.reshape(-1, 1) self.stress_im.set_array(np.swapaxes( stress_rgba.reshape((self.nelx, self.nely, 4)), 0, 1)) self.fig.canvas.draw() self.fig.canvas.flush_events() if title is not None: plt.title(title) else: plt.xlabel("Max stress = {:.2f}".format(max(stress)[0])) plt.pause(0.01)
Example #20
Source File: plot_3.py From cs294-112_hws with MIT License | 6 votes |
def plot_3(data): x = data.Iteration.unique() y_mean = data.groupby('Iteration').mean() y_std = data.groupby('Iteration').std() sns.set(style="darkgrid", font_scale=1.5) value = 'AverageReturn' plt.plot(x, y_mean[value], label=data['Condition'].unique()[0] + '_train'); plt.fill_between(x, y_mean[value] - y_std[value], y_mean[value] + y_std[value], alpha=0.2); value = 'ValAverageReturn' plt.plot(x, y_mean[value], label=data['Condition'].unique()[0] + '_test'); plt.fill_between(x, y_mean[value] - y_std[value], y_mean[value] + y_std[value], alpha=0.2); plt.xlabel('Iteration') plt.ylabel('AverageReturn') plt.legend(loc='best')
Example #21
Source File: plot_part1.py From cs294-112_hws with MIT License | 6 votes |
def plot_12(data): r1, r2, r3, r4 = data plt.figure() add_plot(r1, 'MeanReward100Episodes'); add_plot(r1, 'BestMeanReward', 'vanilla DQN'); add_plot(r2, 'MeanReward100Episodes'); add_plot(r2, 'BestMeanReward', 'double DQN'); plt.xlabel('Time step'); plt.ylabel('Reward'); plt.legend(); plt.savefig( os.path.join('results', 'p12.png'), bbox_inches='tight', transparent=True, pad_inches=0.1 )
Example #22
Source File: PSO.py From sopt with MIT License | 5 votes |
def save_plot(self,save_name="PSO.png"): plt.plot(self.generations_best_targets,'r-') plt.xlabel("generations") plt.ylabel("best target function value") plt.title("PSO with %d generations" %self.generations) plt.savefig(save_name)
Example #23
Source File: plot_threshold_vs_success.py From pointnet-registration-framework with MIT License | 5 votes |
def make_plot(files, labels): plt.figure() AUC = [] # Calculate Area under curve for each test folder. (quantification of success) for file_idx in range(len(files)): rot_err, trans_err = read_csv(files[file_idx]) success_dict = count_success_rot(rot_err) x_range = list(success_dict.keys()) x_range.sort() success = [] for i in x_range: success.append(success_dict[i]) # Ratio of successful cases to total test cases. success = np.array(success)/total_cases area = np.trapz(success, dx=0.5) AUC.append(area) plt.plot(x_range, success, linewidth=6, label=labels[file_idx]) plt.xlabel('Rotation Error for Success Criteria', fontsize=40) plt.ylabel('Success Ratio', fontsize=40) plt.tick_params(labelsize=40, width=3, length=10) plt.xticks(np.arange(0,180.5,30)) plt.yticks(np.arange(0,1.1,0.2)) plt.xlim(-0.5,180) plt.ylim(0,1.01) plt.grid(True) plt.legend(fontsize=30, loc=4) AUC = np.array(AUC)/180.0 print('Area Under Curve values: {}'.format(AUC)) np.savetxt('auc.txt',AUC)
Example #24
Source File: plot_part1.py From cs294-112_hws with MIT License | 5 votes |
def plot_11(data): r1, r2, r3, r4 = data plt.figure() add_plot(r1, 'MeanReward100Episodes', 'MeanReward100Episodes'); add_plot(r1, 'BestMeanReward', 'BestMeanReward'); plt.xlabel('Time step'); plt.ylabel('Reward'); plt.legend(); plt.savefig( os.path.join('results', 'p11.png'), bbox_inches='tight', transparent=True, pad_inches=0.1 )
Example #25
Source File: malware.py From trees with Apache License 2.0 | 5 votes |
def ROC(scores, labels, names, name="STD"): max_ACC, TP, FP = ROC_data(scores, labels, names, name) graph_ROC([max_ACC], [TP], [FP], name) #P = len(labels[labels==1]) #N = len(labels[labels==0]) ## Save raw results in a file: #fr = file(r"../scratch/"+name+"_results.txt","w") #for s, l, n in sorted(zip(scores,labels, names), key=lambda x: np.mean(x[0])): # fr.write("%.4f\t%s\t%s\n" % (np.mean(s), int(l), n)) #fr.close() ## Make an ROC curve # acc_max = "%.2f" % max(ACC) #plt.cla() #plt.clf() #plt.close() #plt.plot(FP, TP) #plt.xlim((0,0.1)) #plt.ylim((0,1)) #plt.title('ROC Curve (accuracy=%.2f)' % max_ACC) #plt.xlabel('False Positive Rate') #plt.ylabel('True Positive Rate') #plt.savefig(r"../scratch/"+name+"_ROC_curve.png", bbox_inches='tight') #f = file(r"../scratch/"+name+"_ROC_curve.csv", "w") #f.write("FalsePositive,TruePositive,Accuracy\n") #for fp, tp, acc in zip(FP,TP, ACC): # f.write("%s,%s,%s\n" % (fp, tp, acc)) #f.close() ## Read the csv files
Example #26
Source File: malware.py From trees with Apache License 2.0 | 5 votes |
def graph_ROC(max_ACC, TP, FP, name="STD"): aTP = np.vstack(TP) n = len(TP) mean_TP = np.mean(aTP, axis=0) stderr_TP = np.std(aTP, axis=0) / (n ** 0.5) var_TP = np.var(aTP, axis=0) max_TP = mean_TP + 3 * stderr_TP min_TP = mean_TP - 3 * stderr_TP # sTP = sum(TP) / len(TP) sFP = FP[0] print len(sFP), len(mean_TP), len(TP[0]) smax_ACC = np.mean(max_ACC) plt.cla() plt.clf() plt.close() plt.plot(sFP, mean_TP) plt.fill_between(sFP, min_TP, max_TP, color='black', alpha=0.2) plt.xlim((0,0.1)) plt.ylim((0,1)) plt.title('ROC Curve (accuracy=%.3f)' % smax_ACC) plt.xlabel('False Positive Rate') plt.ylabel('True Positive Rate') plt.savefig(r"../scratch/"+name+"_ROC_curve.pdf", bbox_inches='tight') # Write the data to the file f = file(r"../scratch/"+name+"_ROC_curve.csv", "w") f.write("FalsePositive,TruePositive,std_err, var, n\n") for fp, tp, err, var in zip(sFP, mean_TP, stderr_TP, var_TP): f.write("%s, %s, %s, %s, %s\n" % (fp, tp, err, var, n)) f.close()
Example #27
Source File: results_plotter.py From lirpg with MIT License | 5 votes |
def plot_curves(xy_list, xaxis, title): plt.figure(figsize=(8,2)) maxx = max(xy[0][-1] for xy in xy_list) minx = 0 for (i, (x, y)) in enumerate(xy_list): color = COLORS[i] plt.scatter(x, y, s=2) x, y_mean = window_func(x, y, EPISODES_WINDOW, np.mean) #So returns average of last EPISODE_WINDOW episodes plt.plot(x, y_mean, color=color) plt.xlim(minx, maxx) plt.title(title) plt.xlabel(xaxis) plt.ylabel("Episode Rewards") plt.tight_layout()
Example #28
Source File: gail-eval.py From lirpg with MIT License | 5 votes |
def plot(env_name, bc_log, gail_log, stochastic): upper_bound = bc_log['upper_bound'] bc_avg_ret = bc_log['avg_ret'] gail_avg_ret = gail_log['avg_ret'] plt.plot(CONFIG['traj_limitation'], upper_bound) plt.plot(CONFIG['traj_limitation'], bc_avg_ret) plt.plot(CONFIG['traj_limitation'], gail_avg_ret) plt.xlabel('Number of expert trajectories') plt.ylabel('Accumulated reward') plt.title('{} unnormalized scores'.format(env_name)) plt.legend(['expert', 'bc-imitator', 'gail-imitator'], loc='lower right') plt.grid(b=True, which='major', color='gray', linestyle='--') if stochastic: title_name = 'result/{}-unnormalized-stochastic-scores.png'.format(env_name) else: title_name = 'result/{}-unnormalized-deterministic-scores.png'.format(env_name) plt.savefig(title_name) plt.close() bc_normalized_ret = bc_log['normalized_ret'] gail_normalized_ret = gail_log['normalized_ret'] plt.plot(CONFIG['traj_limitation'], np.ones(len(CONFIG['traj_limitation']))) plt.plot(CONFIG['traj_limitation'], bc_normalized_ret) plt.plot(CONFIG['traj_limitation'], gail_normalized_ret) plt.xlabel('Number of expert trajectories') plt.ylabel('Normalized performance') plt.title('{} normalized scores'.format(env_name)) plt.legend(['expert', 'bc-imitator', 'gail-imitator'], loc='lower right') plt.grid(b=True, which='major', color='gray', linestyle='--') if stochastic: title_name = 'result/{}-normalized-stochastic-scores.png'.format(env_name) else: title_name = 'result/{}-normalized-deterministic-scores.png'.format(env_name) plt.ylim(0, 1.6) plt.savefig(title_name) plt.close()
Example #29
Source File: classification.py From Kaggler with MIT License | 5 votes |
def plot_pr_curve(y, p): precision, recall, _ = precision_recall_curve(y, p) plt.step(recall, precision, color='b', alpha=0.2, where='post') plt.fill_between(recall, precision, step='post', alpha=0.2, color='b') plt.xlabel('Recall') plt.ylabel('Precision') plt.ylim([0.0, 1.05]) plt.xlim([0.0, 1.0])
Example #30
Source File: results_plotter.py From HardRLWithYoutube with MIT License | 5 votes |
def plot_curves(xy_list, xaxis, title): plt.figure(figsize=(8,2)) maxx = max(xy[0][-1] for xy in xy_list) minx = 0 for (i, (x, y)) in enumerate(xy_list): color = COLORS[i] plt.scatter(x, y, s=2) x, y_mean = window_func(x, y, EPISODES_WINDOW, np.mean) #So returns average of last EPISODE_WINDOW episodes plt.plot(x, y_mean, color=color) plt.xlim(minx, maxx) plt.title(title) plt.xlabel(xaxis) plt.ylabel("Episode Rewards") plt.tight_layout()