LSCP.fit overwrites its own n_bins and random_state parameters
Author: owgreen-devCreated Sep 20, 2026Updated Sep 20, 2026
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.
Source: yzhao062/pyod