Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listing 4.6: errors should be absolute values? #15

Open
mehaase opened this issue Jul 29, 2021 · 0 comments
Open

Listing 4.6: errors should be absolute values? #15

mehaase opened this issue Jul 29, 2021 · 0 comments

Comments

@mehaase
Copy link

mehaase commented Jul 29, 2021

The first line in the listing sums the error values, but since some errors are positive and some are negative, they have the effect of cancelling out and lowering the error measurement.

>>> avg_error = functools.reduce(lambda a,b: a+b, (trY2-Y_train))
10683.684611765864

I believe it should be:

>>> avg_error = functools.reduce(lambda a,b: a+b, np.abs(trY2-Y_train))
178465.4145040395

Or even more succinctly, reuse the error vector computed in an earlier step:

>>> avg_error = np.sum(error)
178465.41450403954
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant