Python icon indicating copy to clipboard operation
Python copied to clipboard

Improve ML docs/tests

Open MichaeINeumann opened this issue 1 month ago • 0 comments

Describe your change:

  • [ ] Add an algorithm?
  • [ ] Fix a bug or typo in an existing algorithm?
  • [x] Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • [x] 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.
  • [x] 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.
  • [x] 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".

Summary

  • improve k-means docstrings/type hints and add convergence doctests
  • refactor gradient descent helpers and add targeted unit tests
  • add typed linear regression docs/examples and new ML pytest module

Testing

  • .venv/bin/pre-commit run --files machine_learning/k_means_clust.py machine_learning/linear_regression.py machine_learning/gradient_descent.py machine_learning/test_machine_learning_algorithms.py
  • .venv/bin/python -m pytest machine_learning/test_machine_learning_algorithms.py

Fixes #13919

MichaeINeumann avatar Dec 17 '25 19:12 MichaeINeumann