def _mean_var(frame, weights=None): """ Compute the (weighted) mean and variance. :param frame: Single column H2OFrame :param weights: optional weights column :returns: The (weighted) mean and variance """ return _colmean(frame), frame.var()
def _mean_var(frame, weights=None): """ Compute the (weighted) mean and variance :param frame: Single column H2OFrame :param weights: optional weights column :return: The (weighted) mean and variance """ return _colmean(frame), frame.var()
def h2o_mean_squared_error(y_actual, y_predicted, weights=None): """ Mean squared error regression loss :param y_actual: H2OFrame of actual response. :param y_predicted: H2OFrame of predicted response. :param weights: (Optional) sample weights :returns: mean squared error loss (best is 0.0). """ ModelBase._check_targets(y_actual, y_predicted) return _colmean((y_predicted - y_actual)**2)
def h2o_mean_squared_error(y_actual, y_predicted, weights=None): """ Mean squared error regression loss :param y_actual: H2OFrame of actual response. :param y_predicted: H2OFrame of predicted response. :param weights: (Optional) sample weights :return: loss (float) (best is 0.0) """ ModelBase._check_targets(y_actual, y_predicted) return _colmean((y_predicted - y_actual) ** 2)
def h2o_mean_absolute_error(y_actual, y_predicted, weights=None): """ Mean absolute error regression loss. :param y_actual: H2OFrame of actual response. :param y_predicted: H2OFrame of predicted response. :param weights: (Optional) sample weights :return: loss (float) (best is 0.0) """ ModelBase._check_targets(y_actual, y_predicted) return _colmean((y_predicted - y_actual).abs())
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^2 (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 :return: R^2 (float) (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