def sum_of_squares(x, y, fn):
    """
    Calculates error between training set and our approximation
    Residential sum of squares: sum(|f(x) - y|^2)
    for all (x,y) in out training set
    :return: float which represents error
    """
    return sum([(i - j) ** 2 for i, j in zip(map(fn, x), y)])