def h2o_r2_score(y_actual, y_predicted, weights=1.):
    """
    R-squared (coefficient of determination) regression score function

    :param y_actual: H2OFrame of actual response.
    :param y_predicted: H2OFrame of predicted response.
    :param weights: (Optional) sample weights
    :returns: R-squared (best is 1.0, lower is worse).
    """
    ModelBase._check_targets(y_actual, y_predicted)
    numerator = (weights * (y_actual - y_predicted) ** 2).sum()
    denominator = (weights * (y_actual - _colmean(y_actual)) ** 2).sum()

    if denominator == 0.0:
        return 1. if numerator == 0. else 0.  # 0/0 => 1, else 0
    return 1 - numerator / denominator
def h2o_r2_score(y_actual, y_predicted, weights=1.):
    """
    R-squared (coefficient of determination) regression score function

    :param y_actual: H2OFrame of actual response.
    :param y_predicted: H2OFrame of predicted response.
    :param weights: (Optional) sample weights
    :returns: R-squared (best is 1.0, lower is worse).
    """
    ModelBase._check_targets(y_actual, y_predicted)
    numerator = (weights * (y_actual - y_predicted) ** 2).sum()
    denominator = (weights * (y_actual - _colmean(y_actual)) ** 2).sum()

    if denominator == 0.0:
        return 1. if numerator == 0. else 0.  # 0/0 => 1, else 0
    return 1 - numerator / denominator
def h2o_r2_score ( y_actual , y_predicted , weights = 1. ) : ModelBase . _check_targets ( y_actual , y_predicted ) numerator = ( weights * ( y_actual - y_predicted ) ** 2 ) . sum ( ) denominator = ( weights * ( y_actual - _colmean ( y_actual ) ) ** 2 ) . sum ( ) if denominator == 0.0 : return 1. if numerator == 0. else 0. # 0/0 => 1, else 0 return 1 - numerator / denominator
R-squared (coefficient of determination) regression score function

    :param y_actual: H2OFrame of actual response.
    :param y_predicted: H2OFrame of predicted response.
    :param weights: (Optional) sample weights
    :returns: R-squared (best is 1.0, lower is worse).
R - squared ( coefficient of determination ) regression score function