Skip to content

Make NotInitializedError a subclass of NotFittedError #859

Closed
@timokau

Description

@timokau

Hi,

currently calling predict on an uninitialized estimator throws a NotInitializedError instead of scikit-learn's NotFittedError. This is problematic in cases where we want to be able to handle different kinds of estimators while providing some kind of fallback behavior. Currently we need

try:
    prediction = estimator.predict(X)
except (NotFittedError, NotInitializedError):
    # some fallback behavior

I think it would be better if NotInitializedError was a subclass of NotFittedError. In that case we could treat an skorch estimator like a regular scikit-learn estimator and simply catch NotFittedError.

Would a PR in that direction be welcome?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions