def aic(eval_data, predictions, scores, learner):
    '''
    Return Akaike information criterion (AIC) scores for the given
    `learner` producing the given `scores` (log likelihoods in base e):

        aic = 2 * learner.num_params - 2 * sum(log_2(exp(scores)))

    The result is a list *one element longer* than the number of scores:
    the last element of this list is the penalty for the learner from the
    number of parameters, and the others are negative log likelihoods in
    base 2.

    The standard way to aggregate this metric is to sum the resulting list.

    >>> learner = Learner(); learner.num_params = 1024
    >>> aic(None, None, [np.log(0.5), np.log(0.125), np.log(0.25), np.log(0.5)], learner)
    [2.0, 6.0, 4.0, 2.0, 2048.0]
    '''
    return (-2.0 * np.array(scores) / np.log(2.0)).tolist() + [2.0 * float(learner.num_params)]
def aic ( eval_data , predictions , scores , learner ) : return ( - 2.0 * np . array ( scores ) / np . log ( 2.0 ) ) . tolist ( ) + [ 2.0 * float ( learner . num_params ) ]
Return Akaike information criterion (AIC) scores for the given
    `learner` producing the given `scores` (log likelihoods in base e):

        aic = 2 * learner.num_params - 2 * sum(log_2(exp(scores)))

    The result is a list *one element longer* than the number of scores:
    the last element of this list is the penalty for the learner from the
    number of parameters, and the others are negative log likelihoods in
    base 2.

    The standard way to aggregate this metric is to sum the resulting list.

    >>> learner = Learner(); learner.num_params = 1024
    >>> aic(None, None, [np.log(0.5), np.log(0.125), np.log(0.25), np.log(0.5)], learner)
    [2.0, 6.0, 4.0, 2.0, 2048.0]