pyod
pyod copied to clipboard
predict_proba : IndexError: index 1 is out of bounds for axis 1 with size 1
Some issues when predict_proba with HBOS, ABOD models.
probs seems one dimension !!!!!!
C:\D\anaconda3\envs\py36\lib\site-packages\pyod\models\base.py in predict_proba(self, X, method)
204 scaler = MinMaxScaler().fit(train_scores.reshape(-1, 1))
205 probs[:, 1] = scaler.transform(
--> 206 test_scores.reshape(-1, 1)).ravel().clip(0, 1)
207 probs[:, 0] = 1 - probs[:, 1]
208 return probs
IndexError: index 1 is out of bounds for axis 1 with size 1
> c:\d\anaconda3\envs\py36\lib\site-packages\pyod\models\base.py(206)predict_proba()
204 scaler = MinMaxScaler().fit(train_scores.reshape(-1, 1))
205 probs[:, 1] = scaler.transform(
--> 206 test_scores.reshape(-1, 1)).ravel().clip(0, 1)
207 probs[:, 0] = 1 - probs[:, 1]
208 return probs
ipdb> test_scores
array([ -0. , -45.25394496, -0. , ..., -0. ,
-404.05396667, -146.66039545])
ipdb> test_scores.reshape(-1, 1)
array([[ -0. ],
[ -45.25394496],
[ -0. ],
...,
[ -0. ],
[-404.05396667],
[-146.66039545]])
ipdb> test_scores.reshape(-1, 1)).ravel()
*** SyntaxError: invalid syntax
ipdb> test_scores.reshape(-1, 1).ravel()
array([ -0. , -45.25394496, -0. , ..., -0. ,
-404.05396667, -146.66039545])
ipdb> scaler.transform(
--> 206 test_scores.reshape(-1, 1))
*** SyntaxError: invalid syntax
ipdb> scaler.transform( test_scores.reshape(-1, 1))
array([[1.],
[1.],
[1.],
...,
[1.],
[1.],
[1.]])
ipdb> scaler.transform( test_scores.reshape(-1, 1)).
ravel()
array([1., 1., 1., ..., 1., 1., 1.])
ipdb> scaler.transform( test_scores.reshape(-1, 1)).
ravel().clip(0, 1)
array([1., 1., 1., ..., 1., 1., 1.])
ipdb> probs
array([[0.],
[0.],
[0.],
...,
[0.],
[0.],
[0.]])
in base.py
Code should be : self._classes = max(2, len(np.unique(y)) )
to prevent having only one class