Skip to content

Added mean absolute error in linear regression #7003

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

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Caeden Perelli-Harris <caedenperelliharris@gmail.com>
  • Loading branch information
cclauss and CaedenPH authored Oct 30, 2022
commit b26c1ca9b178aecac8b309a9809b6531a80a783c
7 changes: 2 additions & 5 deletions machine_learning/linear_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,8 @@ def mean_absolute_error(predicted_y, original_y):
:param original_y : contains values of expected outcome
:return : mean absolute error computed from given feature's
"""
total = 0
for i in range(len(original_y)):
total += abs(original_y[i] - predicted_y[i])
error = total / len(original_y)
return error
total = sum(abs(original_y[i] - predicted_y[i]) for i in range(len(original_y)))
return total / len(original_y)


def main():
Expand Down