benchmark/code/recnn/evaluate.py
def generate_results(y_test, y_score, batch_size, output_dir, weights=None):
    """Make ROC with area under the curve plot."""
    logging.info('length y_test={}'.format(len(y_test)))
    logging.info('Lenght y_score={}'.format(len(y_score)))
    if weights is not None:
        logging.info('Sample weights length={}'.format(len(weights)))
        # We include the weights until the last full batch (the remaining ones
        # are not enough to make a full batch)
        last_weight = len(weights) - len(weights) % batch_size
        weights = weights[0:last_weight]
        logging.info('New sample weights length={}'.format(len(weights)))
    fpr, tpr, thresholds = roc_curve(
        y_test,
        y_score,
        pos_label=1,
        drop_intermediate=False
    )
    logging.info('Length y_score {}'.format(len(y_score)))
    logging.info('Length y_test {}'.format(len(y_test)))
    logging.info('Thresholds[0:6] = \n {}'.format(thresholds[:6]))
    logging.info('Thresholds lenght = \n{}'.format(len(thresholds)))
    logging.info('fpr lenght{}'.format(len(fpr)))
    logging.info('tpr lenght{}'.format(len(tpr)))
    if weights is not None:
        logging.info('Sample weights length={}'.format(len(weights)))
        logging.info('Sample weights[0:4]={}'.format(weights[0:4]))
    # Save fpr, tpr to output file
    output_file = os.path.join(output_dir, fn.ROC_FILE)
    with open(output_file, 'wb') as f:
        pickle.dump(zip(fpr, tpr), f)
    roc_auc = roc_auc_score(y_test, y_score)
    logging.info('roc_auc={}'.format(roc_auc))
    return roc_auc
Make ROC with area under the curve plot.
Make ROC with area under the curve plot.
Make ROC with area under the curve plot .
def generate_results(y_test, y_score, batch_size, output_dir, weights=None):
    logging.info('length y_test={}'.format(len(y_test)))
    logging.info('Lenght y_score={}'.format(len(y_score)))
    if weights is not None:
        logging.info('Sample weights length={}'.format(len(weights)))
        last_weight = len(weights) - len(weights) % batch_size
        weights = weights[0:last_weight]
        logging.info('New sample weights length={}'.format(len(weights)))
    fpr, tpr, thresholds = roc_curve(
        y_test,
        y_score,
        pos_label=1,
        drop_intermediate=False
    )
    logging.info('Length y_score {}'.format(len(y_score)))
    logging.info('Length y_test {}'.format(len(y_test)))
    logging.info('Thresholds[0:6] = \n {}'.format(thresholds[:6]))
    logging.info('Thresholds lenght = \n{}'.format(len(thresholds)))
    logging.info('fpr lenght{}'.format(len(fpr)))
    logging.info('tpr lenght{}'.format(len(tpr)))
    if weights is not None:
        logging.info('Sample weights length={}'.format(len(weights)))
        logging.info('Sample weights[0:4]={}'.format(weights[0:4]))
    output_file = os.path.join(output_dir, fn.ROC_FILE)
    with open(output_file, 'wb') as f:
        pickle.dump(zip(fpr, tpr), f)
    roc_auc = roc_auc_score(y_test, y_score)
    logging.info('roc_auc={}'.format(roc_auc))
    return roc_auc
def generate_results ( y_test , y_score , batch_size , output_dir , weights = None ) : logging . info ( 'length y_test={}' . format ( len ( y_test ) ) ) logging . info ( 'Lenght y_score={}' . format ( len ( y_score ) ) ) if weights is not None : logging . info ( 'Sample weights length={}' . format ( len ( weights ) ) ) last_weight = len ( weights ) - len ( weights ) % batch_size weights = weights [ 0 : last_weight ] logging . info ( 'New sample weights length={}' . format ( len ( weights ) ) ) fpr , tpr , thresholds = roc_curve ( y_test , y_score , pos_label = 1 , drop_intermediate = False ) logging . info ( 'Length y_score {}' . format ( len ( y_score ) ) ) logging . info ( 'Length y_test {}' . format ( len ( y_test ) ) ) logging . info ( 'Thresholds[0:6] = \n {}' . format ( thresholds [ : 6 ] ) ) logging . info ( 'Thresholds lenght = \n{}' . format ( len ( thresholds ) ) ) logging . info ( 'fpr lenght{}' . format ( len ( fpr ) ) ) logging . info ( 'tpr lenght{}' . format ( len ( tpr ) ) ) if weights is not None : logging . info ( 'Sample weights length={}' . format ( len ( weights ) ) ) logging . info ( 'Sample weights[0:4]={}' . format ( weights [ 0 : 4 ] ) ) output_file = os . path . join ( output_dir , fn . ROC_FILE ) with open ( output_file , 'wb' ) as f : pickle . dump ( zip ( fpr , tpr ) , f ) roc_auc = roc_auc_score ( y_test , y_score ) logging . info ( 'roc_auc={}' . format ( roc_auc ) ) return roc_auc
Make ROC with area under the curve plot.
Make ROC with area under the curve plot .
"""Make ROC with area under the curve plot.""" # We include the weights until the last full batch (the remaining ones # are not enough to make a full batch) # Save fpr, tpr to output file
y_test
y_score
batch_size
output_dir
weights