Skip to content

Getters for hyperparameters of models #260

@lars-reimann

Description

@lars-reimann

Is your feature request related to a problem?

It's currently not possible to check the values of hyperparameters of a classifier or regressor using the public API. Since they can only be created by calling the constructor this is not a major issue, yet. However, in the future we might also add capabilities to load pre-trained models. Then the values of their hyperparameters are no longer obvious.

Desired solution

For each hyperparameter of a classifier or regressor add a @property method (a getter). We do NOT want setters in order to maintain immutability. The name of the method should be the same as the name of the attribute with the leading underscore removed.

Example (AdaBoost):

class AdaBoost(Classifier):
    def __init__(self, learning_rate: float = 1.0) -> None:
        # ...
        self._learning_rate = learning_rate

    @property
    def learning_rate(self) -> float:
        return self._learning_rate

Possible alternatives (optional)

No response

Screenshots (optional)

No response

Additional Context (optional)

To test the getters, use them in the existing tests instead of directly accessing the internal attributes (i.e. replace classifier._learning_rate with classifier.learning_rate.

Metadata

Metadata

Labels

Type

No type

Projects

Status

✔️ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions