Title: Make random forest classifier testable by pruthvirajgojare-source · Pull Request #98 · S-AI-Projects/TheAlgorithms-Python · GitHub
Open Graph Title: Make random forest classifier testable by pruthvirajgojare-source · Pull Request #98 · S-AI-Projects/TheAlgorithms-Python
X Title: Make random forest classifier testable by pruthvirajgojare-source · Pull Request #98 · S-AI-Projects/TheAlgorithms-Python
Description: Description Adds a deterministic, testable accuracy function to the random forest Iris example. Previously, pytest collected no tests from the file because it had no doctests and only a manually invoked main() demo. Related Issue Not applicable. Fixes: N/A Type of Change Bug Fix New Feature UI/UX Improvement Performance Improvement Tests Documentation Refactoring / Maintenance CI/CD Changes Made Added typed random_forest_accuracy() -> float, using fixed random_state values for the Iris train/test split and classifier, and returning test accuracy. Added a doctest asserting accuracy is greater than 0.9. Kept main() as the plotting demo. Added work/R23-T045/CI_NOTES.md with findings about pytest collection, coverage and ignores, DIRECTORY.md generation, and filename validation. Screenshots / Recordings Not applicable; this change does not affect a UI. Testing uv run pytest machine_learning/random_forest_classifier.py --cov=machine_learning --cov-report=term-missing -v — passed; 1 doctest passed, target file coverage 57% (the demo remains uncovered). uv run pytest machine_learning/random_forest_classifier.py -v — passed; 1 doctest passed. uvx ruff check machine_learning/random_forest_classifier.py — passed. uvx ruff format --check machine_learning/random_forest_classifier.py — passed. uv run scripts/validate_filenames.py — passed. uv run pytest machine_learning -v — 192 passed, 1 unrelated failure in linear_discriminant_analysis.py: expected 6.4494456086997705, got 6.449445608699771. Checklist I have tested my changes locally. I have added or updated tests, if needed. I have updated documentation, if needed. I have followed the project coding guidelines. I have run the relevant tests and checks. I have addressed previous review feedback, if applicable. Additional Notes The CI workflow runs pytest with --doctest-modules; before the change, the focused test collected 0 items and exited 5. The target file is not ignored by CI. DIRECTORY.md is generated by scripts/build_directory_md.py and was not hand-edited. The separate upstream/R23-T045 branch contains only the code change and excludes work/. Instructor review has not been requested because no instructor GitHub username was provided.
Open Graph Description: Description Adds a deterministic, testable accuracy function to the random forest Iris example. Previously, pytest collected no tests from the file because it had no doctests and only a manually i...
X Description: Description Adds a deterministic, testable accuracy function to the random forest Iris example. Previously, pytest collected no tests from the file because it had no doctests and only a manually i...
Opengraph URL: https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/98
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:f7657654-0d59-cc76-efe4-893e1d8475d0 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | A400:31D1B5:FA097:162246:6AFDF882 |
| html-safe-nonce | c1821281cdb6a7fc24296a5dc8449e10c0a35b4f9fe8b9e24ea1db2946875f03 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDAwOjMxRDFCNTpGQTA5NzoxNjIyNDY6NkFGREY4ODIiLCJ2aXNpdG9yX2lkIjoiMjc3MDQyODM4NTQ0MTg1NDc0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | fcf6ef13bc58ea7ebc5a4857f830c33c5b2d989bcca4ceecb29e8869ed7f915c |
| hovercard-subject-tag | pull_request:5371632166 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/S-AI-Projects/TheAlgorithms-Python/pull/98/files |
| twitter:image | https://avatars.githubusercontent.com/u/295325153?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/295325153?s=400&v=4 |
| og:image:alt | Description Adds a deterministic, testable accuracy function to the random forest Iris example. Previously, pytest collected no tests from the file because it had no doctests and only a manually i... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | ee3343385a977757dd145b28fabf4a119780f2615a5a36c5a89f66c9b3b5616d |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/S-AI-Projects/TheAlgorithms-Python git https://github.com/S-AI-Projects/TheAlgorithms-Python.git |
| octolytics-dimension-user_id | 351892385 |
| octolytics-dimension-user_login | S-AI-Projects |
| octolytics-dimension-repository_id | 1444141022 |
| octolytics-dimension-repository_nwo | S-AI-Projects/TheAlgorithms-Python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 63476337 |
| octolytics-dimension-repository_parent_nwo | TheAlgorithms/Python |
| octolytics-dimension-repository_network_root_id | 63476337 |
| octolytics-dimension-repository_network_root_nwo | TheAlgorithms/Python |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 43ae91995f6e2d5ff7a491f3de438f1f723adeaa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width