Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cgsdfc committed Sep 9, 2022
1 parent ee000d7 commit 39325be
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
12 changes: 6 additions & 6 deletions Application.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,11 @@ def run(self) -> None:
sig.emit(key)


# if __name__ == "__main__":
# import sys
if __name__ == "__main__":
import sys

# app = QtWidgets.QApplication(sys.argv)
app = QtWidgets.QApplication(sys.argv)

# w = MyWindow()
# w.show()
# sys.exit(app.exec_())
w = MyWindow()
w.show()
sys.exit(app.exec_())
16 changes: 14 additions & 2 deletions OutlierDetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from numpy import ndarray
from pyod.models.base import BaseDetector
from pathlib import Path as P
import os


def ensure_dir(dir: P):
Expand All @@ -35,6 +36,15 @@ def ensure_dir(dir: P):
MEMORY = Memory(location=CACHE_DIR, verbose=VERBOSE)
NUM_JOBS = 1

EAGER = os.getenv('ODQT_EAGER', '')
if EAGER:
LOG.info('EAGER loading pyod modules...')
import PYODLIBS
LOG.info('Done')
else:
PYODLIBS = None


def tsne(X: ndarray) -> ndarray:
return TSNE(n_jobs=1).fit_transform(X)

Expand Down Expand Up @@ -70,7 +80,7 @@ def _load_data(self: DataConfig):
d.X_train2d, d.X_test2d = Parallel(1)(
delayed(tsne)(X) for X in [d.X_train, d.X_test])
LOG.info('End TSNE')

return d

return _load_data(self)
Expand Down Expand Up @@ -158,7 +168,7 @@ def _discover_models(raw_text: str):
def __init__(self, **renames) -> None:
self.module_map = self.discover_models()
self.real2display = renames
self.display2real = {val:key for key, val in renames.items()}
self.display2real = {val: key for key, val in renames.items()}

def load(self, disname: str) -> Type[BaseDetector]:
"""Load a model class by its namae
Expand All @@ -170,6 +180,8 @@ def load(self, disname: str) -> Type[BaseDetector]:
"""
name = self.dis2real(disname)
assert name in self.module_map, f"Bad model {name}"
if EAGER:
return getattr(PYODLIBS, name)

@MEMORY.cache
def _load_modelcls(self: ModelZoo, name: str):
Expand Down
10 changes: 10 additions & 0 deletions PYODLIBS.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from pyod.models.abod import ABOD
from pyod.models.auto_encoder import AutoEncoder
from pyod.models.cblof import CBLOF
from pyod.models.hbos import HBOS
from pyod.models.iforest import IForest
from pyod.models.knn import KNN
from pyod.models.lof import LOF
from pyod.models.mcd import MCD
from pyod.models.ocsvm import OCSVM
from pyod.models.pca import PCA

0 comments on commit 39325be

Please sign in to comment.