def experiment(objective, label_type, data):
    """Measure performance of an objective.

    Parameters
    ----------
    objective : string 'binary' or 'xentropy'
        Objective function.
    label_type : string 'binary' or 'probability'
        Type of the label.
    data : dict
        Data for training.

    Returns
    -------
    result : dict
        Experiment summary stats.
    """
    np.random.seed(0)
    nrounds = 5
    lgb_data = data['lgb_with_' + label_type + '_labels']
    params = {
        'objective': objective,
        'feature_fraction': 1,
        'bagging_fraction': 1,
        'verbose': -1
    }
    time_zero = time.time()
    gbm = lgb.train(params, lgb_data, num_boost_round=nrounds)
    y_fitted = gbm.predict(data['X'])
    y_true = data[label_type + '_labels']
    duration = time.time() - time_zero
    return {
        'time': duration,
        'correlation': np.corrcoef(y_fitted, y_true)[0, 1],
        'logloss': log_loss(y_fitted, y_true)
    }
def experiment ( objective , label_type , data ) : np . random . seed ( 0 ) nrounds = 5 lgb_data = data [ 'lgb_with_' + label_type + '_labels' ] params = { 'objective' : objective , 'feature_fraction' : 1 , 'bagging_fraction' : 1 , 'verbose' : - 1 } time_zero = time . time ( ) gbm = lgb . train ( params , lgb_data , num_boost_round = nrounds ) y_fitted = gbm . predict ( data [ 'X' ] ) y_true = data [ label_type + '_labels' ] duration = time . time ( ) - time_zero return { 'time' : duration , 'correlation' : np . corrcoef ( y_fitted , y_true ) [ 0 , 1 ] , 'logloss' : log_loss ( y_fitted , y_true ) }
Measure performance of an objective.

    Parameters
    ----------
    objective : string 'binary' or 'xentropy'
        Objective function.
    label_type : string 'binary' or 'probability'
        Type of the label.
    data : dict
        Data for training.

    Returns
    -------
    result : dict
        Experiment summary stats.