Skip to content

Fix SKLearnClassifier and SKLearnRegressor examples #21385

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 7 commits into from
Jun 17, 2025

Conversation

timovdk
Copy link
Contributor

@timovdk timovdk commented Jun 16, 2025

The examples in the docstrings for SKLearnClassifier and SKLearnRegressor are currently not working. This PR addresses the problems mentioned in, and closes #21384:

  • General Fixes:
    • Import layers from keras.layers
    • Import Model from keras.models
    • Remove unnecessary []
  • SKLearnClassifier Fix:
    • Use a 2 class classification problem as an example (instead of the 3 class example)
  • SKLearnRegressor Fix:
    • Use linear activation because it is a regression problem that does not fall between [0, 1]

@codecov-commenter
Copy link

codecov-commenter commented Jun 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.67%. Comparing base (764ed95) to head (2baee33).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #21385   +/-   ##
=======================================
  Coverage   82.67%   82.67%           
=======================================
  Files         565      565           
  Lines       55064    55064           
  Branches     8569     8569           
=======================================
  Hits        45525    45525           
  Misses       7441     7441           
  Partials     2098     2098           
Flag Coverage Δ
keras 82.48% <ø> (ø)
keras-jax 63.50% <ø> (ø)
keras-numpy 58.67% <ø> (ø)
keras-openvino 33.45% <ø> (ø)
keras-tensorflow 63.91% <ø> (ø)
keras-torch 63.53% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@fchollet fchollet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fixes

@google-ml-butler google-ml-butler bot added kokoro:force-run ready to pull Ready to be merged into the codebase labels Jun 17, 2025
@fchollet fchollet merged commit 6361d73 into keras-team:master Jun 17, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kokoro:force-run ready to pull Ready to be merged into the codebase size:S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation: Docstring examples for SKLearnClassifier and SKLearnRegressor do not work
4 participants