Scaler error due to mutable default argument in LUNAR
Mauradion opened this issue · comments
Raphaël Dion commented
The following script returns a ValueError
:
import numpy as np
from pyod.models import lunar
X1 = np.zeros((10, 1))
X2 = np.zeros((10, 2))
m1 = lunar.LUNAR()
m1.fit(X1)
out1 = m1.predict(X1)
m2 = lunar.LUNAR()
m2.fit(X2)
out2 = m2.predict(X2)
out3 = m1.predict(X1)
This is likely due to the fact that the scaler (sklearn.preprocessing.MinMaxScaler()
) is a mutable default argument of LUNAR.
Proposed solution is to add a deepcopy in the init, such as self.scaler = deepcopy(scaler)
.
If this is the right change, I am willing to do the PR.