Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ tensorboard
matplotlib
numpy
scikit_learn
sktime==0.4.1
sktime
9 changes: 4 additions & 5 deletions src/datasets/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
import numpy as np
import pandas as pd
from tqdm import tqdm
from sktime.utils import load_data

from datasets import utils
from .utils import load_from_tsfile_to_dataframe

logger = logging.getLogger('__main__')

Expand Down Expand Up @@ -283,10 +282,10 @@ def load_single(self, filepath):
# Every row of the returned df corresponds to a sample;
# every column is a pd.Series indexed by timestamp and corresponds to a different dimension (feature)
if self.config['task'] == 'regression':
df, labels = utils.load_from_tsfile_to_dataframe(filepath, return_separate_X_and_y=True, replace_missing_vals_with='NaN')
df, labels = load_from_tsfile_to_dataframe(filepath, return_separate_X_and_y=True, replace_missing_vals_with='NaN')
labels_df = pd.DataFrame(labels, dtype=np.float32)
elif self.config['task'] == 'classification':
df, labels = load_data.load_from_tsfile_to_dataframe(filepath, return_separate_X_and_y=True, replace_missing_vals_with='NaN')
df, labels = load_from_tsfile_to_dataframe(filepath, return_separate_X_and_y=True, replace_missing_vals_with='NaN')
labels = pd.Series(labels, dtype="category")
self.class_names = labels.cat.categories
labels_df = pd.DataFrame(labels.cat.codes, dtype=np.int8) # int8-32 gives an error when using nn.CrossEntropyLoss
Expand All @@ -299,7 +298,7 @@ def load_single(self, filepath):
else:
df = data
except:
df, _ = utils.load_from_tsfile_to_dataframe(filepath, return_separate_X_and_y=True,
df, _ = load_from_tsfile_to_dataframe(filepath, return_separate_X_and_y=True,
replace_missing_vals_with='NaN')
labels_df = None

Expand Down
6 changes: 4 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,12 @@ def main(config):
collate_fn=lambda x: collate_fn(x, max_len=model.max_len))
test_evaluator = runner_class(model, test_loader, device, loss_module,
print_interval=config['print_interval'], console=config['console'])
aggr_metrics_test, per_batch_test = test_evaluator.evaluate(keep_all=True)
with torch.no_grad():
aggr_metrics_test, per_batch_test = test_evaluator.evaluate(keep_all=True)
print_str = 'Test Summary: '
for k, v in aggr_metrics_test.items():
print_str += '{}: {:8f} | '.format(k, v)
if v is not None:
print_str += '{}: {:8f} | '.format(k, v)
logger.info(print_str)
return

Expand Down