Skip to content

fix: return the sum of squared errors - #15272

Open
LouisDeconinck wants to merge 1 commit into
TheAlgorithms:masterfrom
LouisDeconinck:fix/linear-regression-sse-8847
Open

fix: return the sum of squared errors#15272
LouisDeconinck wants to merge 1 commit into
TheAlgorithms:masterfrom
LouisDeconinck:fix/linear-regression-sse-8847

Conversation

@LouisDeconinck

Copy link
Copy Markdown

Describe your change

sum_of_square_error was documented as returning the sum of squared errors, but it divided that sum by 2 * len_data, returning half the mean squared error instead. This made the regression error report mathematically incorrect. The fix returns the actual sum of squared errors and removes the now-unused length argument.

Fixes #8847

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests?
  • Documentation change?

Checklist

  • I have read CONTRIBUTING.md.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All functions in the changed file have passing doctests.
  • The change is limited to the existing algorithm and its doctest.

@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

machine_learning/linear_regression.py doesn't give optimal coefficients

1 participant