Skip to content

LSCP.fit overwrites its own n_bins and random_state parameters #754

Description

@owgreen-dev

LSCP.fit writes back onto two constructor arguments: self.random_state = check_random_state(self.random_state) (pyod/models/lscp.py:157) and, when n_bins > n_clf, self.n_bins = self.n_clf (lscp.py:379-383).

>>> clf = LSCP(detector_list=[LOF(), KNN()], n_bins=10, random_state=0)
>>> clf.fit(X)
>>> {k: clf.get_params(deep=False)[k] for k in ("n_bins", "random_state")}
{'n_bins': 2, 'random_state': RandomState(MT19937) at 0x...}

After one fit, get_params() no longer describes the estimator the user built, so clone() yields a different configuration. Same defect #737 fixed in Sampling.

Fix: resolve both into locals or n_bins_ / random_state_; leave the constructor arguments untouched. Happy to open the PR.

Verified on v3.6.6; drafted with Claude Code assistance and checked by hand.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions