Python icon indicating copy to clipboard operation
Python copied to clipboard

Update linear_regression.py

Open PurvalBhude opened this issue 1 year ago • 4 comments

add error handling function. it can handle errors and still run the linear regression algorithm.

Describe your change:

Added try-except blocks for network errors while fetching the dataset (requests.exceptions.RequestException). Added error handling for gradient descent and sum of square error calculations to avoid crashing during matrix operations. Ensured that the main function can handle unexpected issues during the linear regression process and print useful debugging messages.

  • [ ] Add an algorithm?
  • [x] Fix a bug or typo in an existing algorithm?
  • [ ] Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • [ ] Documentation change?

Checklist:

  • [x] I have read CONTRIBUTING.md.
  • [x] This pull request is all my own work -- I have not plagiarized.
  • [x] 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.
  • [x] All new Python files are placed inside an existing directory.
  • [x] All filenames are in all lowercase characters with no spaces or dashes.
  • [x] All functions and variable names follow Python naming conventions.
  • [x] All function parameters and return values are annotated with Python type hints.
  • [ ] All functions have doctests that pass the automated testing.
  • [ ] All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • [ ] If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

PurvalBhude avatar Sep 15 '24 10:09 PurvalBhude

Please review the pull request and merge it.

PurvalBhude avatar Sep 16 '24 07:09 PurvalBhude

i am trying enhancing the code's robustness by adding error handling to prevent crashes during key operations like dataset fetching, gradient descent, and error calculations. Specifically, i am ensuring that network issues, matrix operations, and computational errors don't disrupt the linear regression process, providing useful debugging messages instead.

PurvalBhude avatar Sep 20 '24 16:09 PurvalBhude

Can you merge my pull request by reviewing the PR.

PurvalBhude avatar Sep 23 '24 13:09 PurvalBhude

pls merge the this for following issue

Create error handling function in linear regression algorithm of ML #11534

PurvalBhude avatar Oct 14 '24 12:10 PurvalBhude