Explore Library
Code QuizIntermediate

Variance for Regression Trees

Debug a variance function used to score regression-tree splits.

Codepython
def variance(values):
    n = len(values)
    mean = sum(values) / n
    total = 0.0
    for v in values:
        total += (v - mean)
    return total / n

This should return the variance of the target values. What is the bug?