Skip to content

Documentation: Docstring examples for SKLearnClassifier and SKLearnRegressor do not work #21384

@timovdk

Description

@timovdk

The examples in the docstrings for SKLearnClassifier and SKLearnRegressor are currently not working. This is because of several small issues:

  • General issues:
    • Importing layers from keras.src.layers instead of keras.layers
    • Importing Model from keras.src.layers instead of keras.models
    • Unnecessary usage of [] around the output layer
  • SKLearnClassifier docstring issue:
    • The example uses n_classes=3, but this leads to a scikit-learn error: ValueError: n_classes(3) * n_clusters_per_class(2) must be smaller or equal 2**n_informative(2)=4
  • SKLearnRegressor docstring issue:
    • Uses softmax activation where linear would be more appropriate (regression problem that does not fall between [0, 1]), causing warnings.

I will open a PR to address these issues shortly.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions