Esempio n. 1
0
def r_squared(alpha, beta, x, y):
    """the fraction of variation in y captured by the model, which equals
    1 - the fraction of variation in y not captured by the model"""
    if (1.0 - (sum_of_sqerrors(alpha, beta, x, y) /
               total_sum_of_squares(y))) >= 0.75:
        print("1등급 R^2")
    elif (
            1.0 -
        (sum_of_sqerrors(alpha, beta, x, y) / total_sum_of_squares(y))) >= 0.5:
        print("2등급 R^2")
    elif (1.0 - (sum_of_sqerrors(alpha, beta, x, y) /
                 total_sum_of_squares(y))) >= 0.25:
        print("3등급 R^2")
    else:
        print("4등급 R^2")
    return 1.0 - (sum_of_sqerrors(alpha, beta, x, y) / total_sum_of_squares(y))
Esempio n. 2
0
def multiple_r_squared(xs: List[Vector], ys: Vector, beta: Vector) -> float:
    sum_of_squared_errors = sum(error(x, y, beta)**2 for x, y in zip(xs, ys))
    return 1.0 - sum_of_squared_errors / total_sum_of_squares(ys)