Skip to content

Commit

Permalink
fix the import error in testbed (Issue xuhongzuo#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuhongzuo committed Dec 11, 2023
1 parent c2c7566 commit 622e28e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions deepod/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from deepod.version import __version__
from . import core, models
from . import core, models, metrics

__all__ = ['__version__', 'core', 'models']
__all__ = ['__version__', 'core', 'models', 'metrics']
4 changes: 4 additions & 0 deletions testbed/testbed_unsupervised_ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"""

import os
import sys

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

import warnings
import argparse
import getpass
Expand Down
13 changes: 7 additions & 6 deletions testbed/testbed_unsupervised_tsad.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"""

import os
import sys

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

import argparse
import getpass
import warnings
Expand Down Expand Up @@ -61,13 +65,11 @@

print(f'Model Configs: {model_configs}')


# # setting result file/folder path
cur_time = time.strftime("%m-%d %H.%M.%S", time.localtime())
os.makedirs(args.output_dir, exist_ok=True)
result_file = os.path.join(args.output_dir, f'{args.model}.{args.flag}.csv')


# # print header in the result file
if not args.silent_header:
f = open(result_file, 'a')
Expand All @@ -81,7 +83,6 @@
print(f'data, adj_auroc, std, adj_ap, std, adj_f1, std, adj_p, std, adj_r, std, time, model', file=f)
f.close()


dataset_name_lst = args.dataset.split(',')

for dataset in dataset_name_lst:
Expand Down Expand Up @@ -150,11 +151,11 @@

for i in range(runs):
start_time = time.time()
print(f'\nRunning [{i+1}/{args.runs}] of [{args.model}] on Dataset [{dataset_name}]')
print(f'\nRunning [{i + 1}/{args.runs}] of [{args.model}] on Dataset [{dataset_name}]')

t1 = time.time()

clf = model_class(**model_configs, random_state=42+i)
clf = model_class(**model_configs, random_state=42 + i)
clf.fit(train_data)
scores = clf.decision_function(test_data)
t = time.time() - t1
Expand All @@ -167,7 +168,7 @@
txt += ', '.join(['%.4f' % a for a in eval_metrics]) + \
', pa, ' + \
', '.join(['%.4f' % a for a in adj_eval_metrics])
txt += f', model, {args.model}, time, {t:.1f} s, runs, {i+1}/{args.runs}'
txt += f', model, {args.model}, time, {t:.1f} s, runs, {i + 1}/{args.runs}'
print(txt)

entries.append(adj_eval_metrics)
Expand Down
4 changes: 0 additions & 4 deletions testbed/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ def read_data(file, split='50%-normal', normalization='z-score', seed=42):
return x_train, y_train, x_test, y_test






def import_ts_data_unsupervised(data_root, data, entities=None, combine=False):
if type(entities) == str:
entities_lst = entities.split(',')
Expand Down

0 comments on commit 622e28e

Please sign in to comment.