import json

def load_hyperopt_best(filename, metric):
    """Read best record from JSON generated by `hyperopt`.

    Parameters
    ----------
    filename : str
        File full path.
    metric : str
        Name of metric you need to maximize.

    Returns
    -------
    tuple(metric, params)
        Optimal params and corresponding metric. 

    Examples
    --------
    >>> load_hyperopt_best("hyperopt.json", 'auc')
    """
    with open(filename, "r") as f:
        searchRC = json.load(f)
    best_m = 0
    for r in searchRC:
        if r[metric] > best_m:
            best_m = r[metric]
            best_params = r['params']
    return best_m, best_params