Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Jun 23, 2023
1 parent cdb8655 commit 28a9efe
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
4 changes: 2 additions & 2 deletions docs/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ About us
Core Development Team
---------------------

Yue Zhao (Ph.D. Student @ Carnegie Mellon University):
Yue Zhao (Assistant Professor @ USC, Ph.D. @ CMU):

- Initialized the project in 2017
- `Homepage <https://www.andrew.cmu.edu/user/yuezhao2/>`_
- `Homepage <https://viterbi-web.usc.edu/~yzhao010/>`_
- `LinkedIn (Yue Zhao) <https://www.linkedin.com/in/yzhao062/>`_

Zain Nasrullah (Data Scientist at RBC; MSc in Computer Science from University of Toronto):
Expand Down
2 changes: 1 addition & 1 deletion pyod/models/thresholds.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def CPD(**kwargs):
- 'kde': Use the kernel density estimation
"""

from pythresh.thresholds.cpd import CPD as CPD_thres
return CPD_thres(**kwargs)

Expand Down
2 changes: 1 addition & 1 deletion pyod/test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_fit_predict(self):
def test_predict_proba(self):
# TODO: create uniform testcases
pass

def test_predict_confidence(self):
# TODO: create uniform testcases
pass
Expand Down
1 change: 0 additions & 1 deletion pyod/test/test_suod.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def test_prediction_proba_parameter(self):
with assert_raises(ValueError):
self.clf.predict_proba(self.X_test, method='something')


def test_prediction_labels_confidence(self):
pred_labels, confidence = self.clf.predict(self.X_test,
return_confidence=True)
Expand Down
42 changes: 23 additions & 19 deletions pyod/test/test_thresholds.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
import os
import sys
import unittest

from packaging.version import Version
from platform import python_version

# noinspection PyProtectedMember
from numpy.testing import (assert_allclose, assert_array_less, assert_equal,
assert_raises)
from packaging.version import Version
from scipy.stats import rankdata
from sklearn.base import clone
from sklearn.metrics import roc_auc_score
Expand All @@ -23,18 +22,18 @@
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))

global py_ver
py_ver = Version(python_version())>Version('3.6.15')
py_ver = Version(python_version()) > Version('3.6.15')


class TestThresholds(unittest.TestCase):
@unittest.skipIf(not py_ver, 'Python 3.6 not included')
def setUp(self):

from pyod.models.thresholds import (AUCP, BOOT, CHAU, CLF, CLUST,
CPD, DECOMP, DSN, EB, FGD, FILTER,
FWFM, GESD, HIST, IQR, KARCH, MAD,
MCST, META, MOLL, MTT, OCSVM, QMCD,
CPD, DECOMP, DSN, EB, FGD, FILTER,
FWFM, GESD, HIST, IQR, KARCH, MAD,
MCST, META, MOLL, MTT, OCSVM, QMCD,
REGR, VAE, WIND, YJ, ZSCORE)

self.n_train = 200
self.n_test = 100
self.contamination = 0.1
Expand All @@ -47,23 +46,24 @@ def setUp(self):
)

self.contam = [AUCP(), BOOT(), CHAU(), CLF(), CLUST(),
CPD(), DECOMP(), DSN(), EB(), FGD(), FILTER(),
FWFM(), GESD(), HIST(), IQR(), KARCH(), MAD(),
MCST(), META(), MOLL(), MTT(), OCSVM(), QMCD(),
CPD(), DECOMP(), DSN(), EB(), FGD(), FILTER(),
FWFM(), GESD(), HIST(), IQR(), KARCH(), MAD(),
MCST(), META(), MOLL(), MTT(), OCSVM(), QMCD(),
REGR(), VAE(), WIND(), YJ(), ZSCORE()]

for contam in self.contam:
self.clf = KDE(contamination=contam)
self.clf.fit(self.X_train)

@unittest.skipIf(not py_ver, 'Python 3.6 not included')
def test_parameters(self):
assert (
hasattr(self.clf, "decision_scores_")
and self.clf.decision_scores_ is not None
hasattr(self.clf, "decision_scores_")
and self.clf.decision_scores_ is not None
)
assert hasattr(self.clf, "labels_") and self.clf.labels_ is not None
assert hasattr(self.clf, "threshold_") and self.clf.threshold_ is not None
assert hasattr(self.clf,
"threshold_") and self.clf.threshold_ is not None
assert hasattr(self.clf, "_mu") and self.clf._mu is not None
assert hasattr(self.clf, "_sigma") and self.clf._sigma is not None

Expand Down Expand Up @@ -111,7 +111,8 @@ def test_prediction_proba_parameter(self):

@unittest.skipIf(not py_ver, 'Python 3.6 not included')
def test_prediction_labels_confidence(self):
pred_labels, confidence = self.clf.predict(self.X_test, return_confidence=True)
pred_labels, confidence = self.clf.predict(self.X_test,
return_confidence=True)
assert_equal(pred_labels.shape, self.y_test.shape)
assert_equal(confidence.shape, self.y_test.shape)
assert confidence.min() >= 0
Expand All @@ -137,10 +138,13 @@ def test_fit_predict(self):
@unittest.skipIf(not py_ver, 'Python 3.6 not included')
def test_fit_predict_score(self):
self.clf.fit_predict_score(self.X_test, self.y_test)
self.clf.fit_predict_score(self.X_test, self.y_test, scoring="roc_auc_score")
self.clf.fit_predict_score(self.X_test, self.y_test, scoring="prc_n_score")
self.clf.fit_predict_score(self.X_test, self.y_test,
scoring="roc_auc_score")
self.clf.fit_predict_score(self.X_test, self.y_test,
scoring="prc_n_score")
with assert_raises(NotImplementedError):
self.clf.fit_predict_score(self.X_test, self.y_test, scoring="something")
self.clf.fit_predict_score(self.X_test, self.y_test,
scoring="something")

@unittest.skipIf(not py_ver, 'Python 3.6 not included')
def test_predict_rank(self):
Expand Down

0 comments on commit 28a9efe

Please sign in to comment.