benchmark/code/plot.py
def plot(
    tagger_results, input_truth_file, start_index, output_file, get_model
):
    """Create plot containing ROC corves for all tagger outputs. Saves the plot
    to the given output file.

    Parameters
    ----------
    tagger_results: list(dict)
        List containing information about the results for each tagger. Each
        item in the list is a dictionary with two elements: the unique tagger
        name ('name') and the path to the tagger result file ('file')
    input_truth_file: string
        Path to the file (labels.pkl) that contains the ground truth data
    start_index: int
        Start index for jet processing.
    output_file: string
        Path to the output file where the plot is stored
    get_model: function
        Function to get model from the tagger runs
    """
    # Load groundtruth labels. Keep only the labels that come after the start
    # index
    with open(input_truth_file, 'rb') as f:
        true_labels = np.asarray(pickle.load(f), dtype=int)
    true_labels = true_labels[start_index:]
    # Load tagger result data. Maintain list of tagger names in order of their
    # appearance in the result list and a dictionary that maps tagger names to
    # their output data.
    tagger_names = list()
    tagger_outputs = dict()
    for tagger in tagger_results:
        t_name = tagger['name']
        tagger_names.append(t_name)
        with open(tagger['file'], 'rb') as f:
            tagger_outputs[t_name] = pickle.load(f)
    tagger_median = get_model(true_labels, tagger_outputs)
    # Shortcut to tagger names and outputs
    base_tpr = np.linspace(0.05, 1, 476)
    # Define line styles for plot
    linestyles = ['-', '--', '-.', ':'] * 10
    for t_name in sorted(tagger_names):
        # Tagger output array
        t_out = tagger_median[t_name]
        fpr, tpr, thresholds = roc_curve(
            true_labels,
            t_out,
            pos_label=1,
            drop_intermediate=False
        )
        # Get error
        inv_fpr = interp(base_tpr, tpr, fpr)
        # Create plot and save to file (if filename is given)
        plt.rcParams['figure.figsize'] = 6, 6
        plt.plot(
            base_tpr,
            1./inv_fpr,
            alpha=1,
            label=str(t_name),
            linestyle=linestyles.pop(0)
        )
        plt.xticks(np.linspace(0, 1, 11))
        plt.xlabel(r"Signal efficiency $\epsilon_S$", fontsize=15)
        plt.ylabel(r"Background rejection $\frac{1}{\epsilon_B}$", fontsize=15)
        plt.xlim([-0.01, 1.02])
        plt.ylim(4, 40000)
        plt.yscale("log")
        plt.legend(loc="best")
        plt.grid(which='both', axis='both', linestyle='--')
        plt.savefig(output_file)
Create plot containing ROC corves for all tagger outputs. Saves the plot
    to the given output file.

    Parameters
    ----------
    tagger_results: list(dict)
        List containing information about the results for each tagger. Each
        item in the list is a dictionary with two elements: the unique tagger
        name ('name') and the path to the tagger result file ('file')
    input_truth_file: string
        Path to the file (labels.pkl) that contains the ground truth data
    start_index: int
        Start index for jet processing.
    output_file: string
        Path to the output file where the plot is stored
    get_model: function
        Function to get model from the tagger runs
    
Create plot containing ROC corves for all tagger outputs. Saves the plot
to the given output file.

Parameters

list(dict)
List containing information about the results for each tagger. Each
item in the list is a dictionary with two elements: the unique tagger
name ('name') and the path to the tagger result file ('file')
input_truth_file: string
Path to the file (labels.pkl) that contains the ground truth data
start_index: int
Start index for jet processing.
output_file: string
Path to the output file where the plot is stored
get_model: function
Function to get model from the tagger runs
Create plot containing ROC corves for all tagger outputs . Saves the plot to the given output file . Parameters list ( dict ) List containing information about the results for each tagger . Each item in the list is a dictionary with two elements : the unique tagger name ( ' name ' ) and the path to the tagger result file ( ' file ' ) input_truth_file : string Path to the file ( labels . pkl ) that contains the ground truth data start_index : int Start index for jet processing . output_file : string Path to the output file where the plot is stored get_model : function Function to get model from the tagger runs
def plot(
    tagger_results, input_truth_file, start_index, output_file, get_model
):
    with open(input_truth_file, 'rb') as f:
        true_labels = np.asarray(pickle.load(f), dtype=int)
    true_labels = true_labels[start_index:]
    tagger_names = list()
    tagger_outputs = dict()
    for tagger in tagger_results:
        t_name = tagger['name']
        tagger_names.append(t_name)
        with open(tagger['file'], 'rb') as f:
            tagger_outputs[t_name] = pickle.load(f)
    tagger_median = get_model(true_labels, tagger_outputs)
    base_tpr = np.linspace(0.05, 1, 476)
    linestyles = ['-', '--', '-.', ':'] * 10
    for t_name in sorted(tagger_names):
        t_out = tagger_median[t_name]
        fpr, tpr, thresholds = roc_curve(
            true_labels,
            t_out,
            pos_label=1,
            drop_intermediate=False
        )
        inv_fpr = interp(base_tpr, tpr, fpr)
        plt.rcParams['figure.figsize'] = 6, 6
        plt.plot(
            base_tpr,
            1./inv_fpr,
            alpha=1,
            label=str(t_name),
            linestyle=linestyles.pop(0)
        )
        plt.xticks(np.linspace(0, 1, 11))
        plt.xlabel(r"Signal efficiency $\epsilon_S$", fontsize=15)
        plt.ylabel(r"Background rejection $\frac{1}{\epsilon_B}$", fontsize=15)
        plt.xlim([-0.01, 1.02])
        plt.ylim(4, 40000)
        plt.yscale("log")
        plt.legend(loc="best")
        plt.grid(which='both', axis='both', linestyle='--')
        plt.savefig(output_file)
def plot ( tagger_results , input_truth_file , start_index , output_file , get_model ) : with open ( input_truth_file , 'rb' ) as f : true_labels = np . asarray ( pickle . load ( f ) , dtype = int ) true_labels = true_labels [ start_index : ] tagger_names = list ( ) tagger_outputs = dict ( ) for tagger in tagger_results : t_name = tagger [ 'name' ] tagger_names . append ( t_name ) with open ( tagger [ 'file' ] , 'rb' ) as f : tagger_outputs [ t_name ] = pickle . load ( f ) tagger_median = get_model ( true_labels , tagger_outputs ) base_tpr = np . linspace ( 0.05 , 1 , 476 ) linestyles = [ '-' , '--' , '-.' , ':' ] * 10 for t_name in sorted ( tagger_names ) : t_out = tagger_median [ t_name ] fpr , tpr , thresholds = roc_curve ( true_labels , t_out , pos_label = 1 , drop_intermediate = False ) inv_fpr = interp ( base_tpr , tpr , fpr ) plt . rcParams [ 'figure.figsize' ] = 6 , 6 plt . plot ( base_tpr , 1. / inv_fpr , alpha = 1 , label = str ( t_name ) , linestyle = linestyles . pop ( 0 ) ) plt . xticks ( np . linspace ( 0 , 1 , 11 ) ) plt . xlabel ( r"Signal efficiency $\epsilon_S$" , fontsize = 15 ) plt . ylabel ( r"Background rejection $\frac{1}{\epsilon_B}$" , fontsize = 15 ) plt . xlim ( [ - 0.01 , 1.02 ] ) plt . ylim ( 4 , 40000 ) plt . yscale ( "log" ) plt . legend ( loc = "best" ) plt . grid ( which = 'both' , axis = 'both' , linestyle = '--' ) plt . savefig ( output_file )
Create plot containing ROC corves for all tagger outputs.
Create plot containing ROC corves for all tagger outputs .
"""Create plot containing ROC corves for all tagger outputs. Saves the plot
    to the given output file.

    Parameters
    ----------
    tagger_results: list(dict)
        List containing information about the results for each tagger. Each
        item in the list is a dictionary with two elements: the unique tagger
        name ('name') and the path to the tagger result file ('file')
    input_truth_file: string
        Path to the file (labels.pkl) that contains the ground truth data
    start_index: int
        Start index for jet processing.
    output_file: string
        Path to the output file where the plot is stored
    get_model: function
        Function to get model from the tagger runs
    """ # Load groundtruth labels. Keep only the labels that come after the start # index # Load tagger result data. Maintain list of tagger names in order of their # appearance in the result list and a dictionary that maps tagger names to # their output data. # Shortcut to tagger names and outputs # Define line styles for plot # Tagger output array # Get error # Create plot and save to file (if filename is given)
tagger_results
input_truth_file
start_index
output_file
get_model