Пример #1
0
def plot(dataset, iteration_name, plot_dir):
    label = iteration_enumerator[iteration_name]
    indices = dataset.loc[:, "trk_originalAlgo"] == label
    sub_dataframe = dataset.loc[indices, :]

    plot_xy(sub_dataframe, "trk_pt", "prediction", "trk_isTrue",
            plot_dir, show_density=True, postfix=iteration_name)
    plot_ROC_comparison(sub_dataframe, "prediction", "trk_mva",
                        "trk_isTrue", plot_dir, postfix=iteration_name)
Пример #2
0
def plot_roc(y_true, y_score, title="Receiver Operating Characteristic"):
    from sklearn.metrics import roc_curve, roc_auc_score
    fpr, tpr, thresholds = roc_curve(y_true, y_score)
    auc_score = roc_auc_score(y_true, y_score)
    from plotting import plot_xy
    plot = plot_xy(fpr, tpr, x_axis="False Positive Rate", y_axis="True Positive Rate", title=title)
    return auc_score, plot
Пример #3
0
def plot_roc(y_true,
             y_score,
             title="Receiver Operating Characteristic",
             **options):
    fpr, tpr, thresholds = roc_curve(y_true, y_score)
    auc_score = roc_auc_score(y_true, y_score)
    plot = plot_xy(fpr,
                   tpr,
                   x_axis="False Positive Rate",
                   y_axis="True Positive Rate",
                   title=title)
    if options.get('roc_output'):
        print("Saving ROC scores to file {}".format(options['roc_output']))
        np.save(options['roc_output'], (fpr, tpr))
    return auc_score, plot
#list of object classes, full list here: 
#http://heasarc.gsfc.nasa.gov/W3Browse/fermi/fermilpsc.html
objcls=['agn','bcu','BCU','bin','bll','BLL','css','fsrq','FSRQ','gal',
        'glc','hmb','nlsy1','NLSY1','nov','psr','PSR','pwn','rdg','RDG',
        'sbg','sey','sfr','snr','spp','ssrq','unkn']

ext_list='ext1_ts' #['ext0_ts','ext1_ts','ext2_ts']


plt.figure(figsize=(8,8),facecolor='w',edgecolor='w')
plt.figure(1)
plotting.plot_aitoff(data,subplot=[2,2,1])

plt.subplot(2,2,2)
plotting.plot_xy(data,x='ts',y='ext2_ts',rangex=[0,1000.],rangey=[0,1000.])

plt.subplot(2,1,2)
plotting.plot_class_stats(data,objcls,out_stats=True)

if args.save_plots:
    plotting.save('figures/%s' % args.output,'png',False,True)

plt.figure(figsize=(8,4),facecolor='w',edgecolor='w')
plt.figure(2)
#this has to be its own figure... tbd
plotting.plot_ts_vs_chi2(data,ext_list='ext2_ts', ndf_chi2=[1.0,2.0])

if args.save_plots:
    plotting.save('figures/%s_ts' % args.output,'png',False,True)