Skip to content

Commit 463c1d9

Browse files
Release v0.2.0 (#155)
* test files * move results * versions * fixes
1 parent 3048ba6 commit 463c1d9

File tree

33 files changed

+54
-60
lines changed

33 files changed

+54
-60
lines changed

MANIFEST.in

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ recursive-include examples *
33
recursive-include results *
44
recursive-include tsml_eval *.py
55
recursive-include tsml_eval/datasets *.ts *.csv
6-
recursive-exclude tsml_eval/publications *.csv *.txt *.ipynb
7-
recursive-exclude tsml_eval/utils *.csv
6+
recursive-include tsml_eval/publications *.csv *.txt *.ipynb
7+
recursive-include tsml_eval/testing/_test_result_files *.csv
88
include .coveragerc
9+
include conftest.py
910
include LICENSE
1011
include MANIFEST.in
1112
include pyproject.toml
@@ -20,6 +21,3 @@ exclude .gitignore
2021
exclude .pre-commit-config.yaml
2122
exclude .readthedocs.yml
2223
exclude sweep.yaml
23-
24-
# these are in _wip currently, may want to remove in the future
25-
recursive-include tsml_eval/_wip *.csv *.ipynb *.sh *.txt

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
`tsml-eval` contains benchmarking and evaluation tools for time series machine learning
1515
algorithms.
1616

17-
The current release of `tsml-eval` is v0.1.1.
17+
The current release of `tsml-eval` is v0.2.0.
1818

1919
## Installation
2020

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "tsml-eval"
7-
version = "0.1.1"
7+
version = "0.2.0"
88
description = "A package for benchmarking time series machine learning tools."
99
authors = [
1010
{name = "Matthew Middlehurst", email = "[email protected]"},

tsml_eval/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""tsml-eval."""
22

3-
__version__ = "0.1.1"
3+
__version__ = "0.2.0"

tsml_eval/estimators/classification/hybrid/hivecote_from_file.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def _fit(self, X, y):
126126
if not self.skip_y_check and len(np.unique(y)) != int(line2[5]):
127127
raise ValueError(
128128
f"n_classes of {path + file_name} does not match X, "
129-
f"expected {len(np.unique(y))}, got {line2[6]}"
129+
f"expected {len(np.unique(y))}, got {line2[5]}"
130130
)
131131

132132
for j in range(n_instances):
@@ -154,7 +154,7 @@ def _fit(self, X, y):
154154

155155
# add a weight to the weight list based on the files accuracy
156156
for acc in acc_list:
157-
self.weights_.append(acc ** self._alpha)
157+
self.weights_.append(acc**self._alpha)
158158

159159
self._use_classifier = [True for _ in range(len(self.classifiers))]
160160
if self.acc_filter is not None:
@@ -166,11 +166,13 @@ def _fit(self, X, y):
166166

167167
if self._acc_filter[0] != "train" and self._acc_filter[0] != "test":
168168
raise ValueError(
169-
f"acc_filter[0] must be 'train' or 'test', got {self._acc_filter[0]}"
169+
f"acc_filter[0] must be 'train' or 'test', got "
170+
f"{self._acc_filter[0]}"
170171
)
171172
elif self._acc_filter[1] <= 0 or self._acc_filter[1] >= 1:
172173
raise ValueError(
173-
f"acc_filter[1] must be in between 0 and 1, got {self._acc_filter[1]}"
174+
"acc_filter[1] must be in between 0 and 1, got "
175+
f"{self._acc_filter[1]}"
174176
)
175177

176178
if self._acc_filter[0] == "test":
@@ -179,10 +181,10 @@ def _fit(self, X, y):
179181
if self.random_state is not None:
180182
file_name = f"testResample{self.random_state}.csv"
181183
else:
182-
file_name = f"testResample.csv"
184+
file_name = "testResample.csv"
183185

184186
acc_list = []
185-
for i, path in enumerate(self.classifiers):
187+
for path in self.classifiers:
186188
f = open(path + file_name, "r")
187189
lines = f.readlines()
188190
line2 = lines[2].split(",")
@@ -213,7 +215,7 @@ def _predict_proba(self, X):
213215
if self.random_state is not None:
214216
file_name = f"testResample{self.random_state}.csv"
215217
else:
216-
file_name = f"testResample.csv"
218+
file_name = "testResample.csv"
217219

218220
dists = np.zeros((n_instances, self.n_classes_))
219221

@@ -226,19 +228,15 @@ def _predict_proba(self, X):
226228
line2 = lines[2].split(",")
227229

228230
# verify file matches data
229-
if len(lines) - 3 != n_instances: # verify n_instances
230-
print(
231-
"ERROR n_instances does not match in: ",
232-
path + file_name,
233-
len(lines) - 3,
234-
n_instances,
231+
if len(lines) - 3 != n_instances:
232+
raise ValueError(
233+
f"n_instances of {path + file_name} does not match X, "
234+
f"expected {X.shape[0]}, got {len(lines) - 3}"
235235
)
236-
if self.n_classes_ != int(line2[5]): # verify n_classes
237-
print(
238-
"ERROR n_classes does not match in: ",
239-
path + file_name,
240-
self.n_classes_,
241-
line2[5],
236+
if self.n_classes_ != int(line2[5]):
237+
raise ValueError(
238+
f"n_classes of {path + file_name} does not match X, "
239+
f"expected {self.n_classes_}, got {line2[5]}"
242240
)
243241

244242
# apply this files weights to the probabilities in the test file
@@ -335,10 +333,10 @@ def get_test_params(cls, parameter_set="default"):
335333
`MyClass(**params)` or `MyClass(**params[i])` creates a valid test instance.
336334
`create_test_instance` uses the first (or only) dictionary in `params`.
337335
"""
338-
from tsml_eval.estimators.classification.hybrid.tests.test_hivecote import _TEST_RESULTS_PATH
336+
from tsml_eval.testing.test_utils import _TEST_RESULTS_PATH
339337

340338
file_paths = [
341-
_TEST_RESULTS_PATH + "TestResults/Test1/",
342-
_TEST_RESULTS_PATH + "TestResults/Test2/",
339+
_TEST_RESULTS_PATH + "/classification/TestResults/Test1/",
340+
_TEST_RESULTS_PATH + "/classification/TestResults/Test2/",
343341
]
344342
return {"classifiers": file_paths, "skip_y_check": True, "random_state": 0}

tsml_eval/estimators/classification/hybrid/tests/test_hivecote.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,28 @@
22

33
__author__ = ["MatthewMiddlehurst"]
44

5-
import os
6-
from pathlib import Path
75

86
import numpy as np
97
from aeon.datasets import load_arrow_head, load_italy_power_demand
108
from aeon.utils._testing.estimator_checks import _assert_array_almost_equal
119
from aeon.utils.estimator_checks import check_estimator
1210

13-
from tsml_eval.estimators.classification.hybrid.hivecote_from_file import \
14-
FromFileHIVECOTE
11+
from tsml_eval.estimators.classification.hybrid.hivecote_from_file import (
12+
FromFileHIVECOTE,
13+
)
14+
from tsml_eval.testing.test_utils import _TEST_RESULTS_PATH
1515

16-
_TEST_RESULTS_PATH = os.path.dirname(Path(__file__).parent.parent.parent.parent.parent) + "/tsml_eval/estimators/classification/hybrid/tests/test_files/"
1716

1817
def test_hivecote_from_file():
1918
"""Test HIVE-COTE from file with ItalyPowerDemand results."""
2019
X_train, y_train = load_italy_power_demand(split="train")
2120
X_test, _ = load_italy_power_demand(split="test")
2221

2322
file_paths = [
24-
_TEST_RESULTS_PATH + "/ItalyPowerDemand/Arsenal/",
25-
_TEST_RESULTS_PATH + "/ItalyPowerDemand/DrCIF/",
26-
_TEST_RESULTS_PATH + "/ItalyPowerDemand/STC/",
27-
_TEST_RESULTS_PATH + "/ItalyPowerDemand/TDE/",
23+
_TEST_RESULTS_PATH + "/classification/Arsenal/Predictions/ItalyPowerDemand/",
24+
_TEST_RESULTS_PATH + "/classification/DrCIF/Predictions/ItalyPowerDemand/",
25+
_TEST_RESULTS_PATH + "/classification/STC/Predictions/ItalyPowerDemand/",
26+
_TEST_RESULTS_PATH + "/classification/TDE/Predictions/ItalyPowerDemand/",
2827
]
2928

3029
hc2 = FromFileHIVECOTE(classifiers=file_paths, random_state=0)
@@ -65,10 +64,10 @@ def test_tuned_hivecote_from_file():
6564
X_test, _ = load_arrow_head(split="test")
6665

6766
file_paths = [
68-
_TEST_RESULTS_PATH + "/ArrowHead/Arsenal/",
69-
_TEST_RESULTS_PATH + "/ArrowHead/DrCIF/",
70-
_TEST_RESULTS_PATH + "/ArrowHead/STC/",
71-
_TEST_RESULTS_PATH + "/ArrowHead/TDE/",
67+
_TEST_RESULTS_PATH + "/classification/Arsenal/Predictions/ArrowHead/",
68+
_TEST_RESULTS_PATH + "/classification/DrCIF/Predictions/ArrowHead/",
69+
_TEST_RESULTS_PATH + "/classification/STC/Predictions/ArrowHead/",
70+
_TEST_RESULTS_PATH + "/classification/TDE/Predictions/ArrowHead/",
7271
]
7372

7473
hc2 = FromFileHIVECOTE(classifiers=file_paths, tune_alpha=True, random_state=0)

tsml_eval/estimators/clustering/consensus/tests/test_from_file_clustering.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import os
2-
from pathlib import Path
3-
41
import numpy as np
52
from aeon.datasets import load_arrow_head
63
from sklearn.metrics import rand_score
74

8-
from tsml_eval.estimators.clustering.consensus.ivc_from_file import \
9-
FromFileIterativeVotingClustering
10-
from tsml_eval.estimators.clustering.consensus.simple_vote_from_file import \
11-
FromFileSimpleVote
12-
13-
14-
_TEST_RESULTS_PATH = os.path.dirname(Path(__file__).parent.parent.parent.parent.parent) + "/tsml_eval/estimators/clustering/consensus/tests/test_files/"
5+
from tsml_eval.estimators.clustering.consensus.ivc_from_file import (
6+
FromFileIterativeVotingClustering,
7+
)
8+
from tsml_eval.estimators.clustering.consensus.simple_vote_from_file import (
9+
FromFileSimpleVote,
10+
)
11+
from tsml_eval.testing.test_utils import _TEST_RESULTS_PATH
1512

1613

1714
def test_from_file_simple_vote():
@@ -20,9 +17,9 @@ def test_from_file_simple_vote():
2017
X_test, y_test = load_arrow_head(split="test")
2118

2219
file_paths = [
23-
_TEST_RESULTS_PATH + "/ArrowHead/PAM-DTW/",
24-
_TEST_RESULTS_PATH + "/ArrowHead/PAM-ERP/",
25-
_TEST_RESULTS_PATH + "/ArrowHead/PAM-MSM/",
20+
_TEST_RESULTS_PATH + "/clustering/PAM-DTW/Predictions/ArrowHead/",
21+
_TEST_RESULTS_PATH + "/clustering/PAM-ERP/Predictions/ArrowHead/",
22+
_TEST_RESULTS_PATH + "/clustering/PAM-MSM/Predictions/ArrowHead/",
2623
]
2724

2825
sv = FromFileSimpleVote(clusterers=file_paths, n_clusters=3, random_state=0)
@@ -43,12 +40,14 @@ def test_from_file_iterative_voting_clustering():
4340
X_test, y_test = load_arrow_head(split="test")
4441

4542
file_paths = [
46-
_TEST_RESULTS_PATH + "/ArrowHead/PAM-DTW/",
47-
_TEST_RESULTS_PATH + "/ArrowHead/PAM-ERP/",
48-
_TEST_RESULTS_PATH + "/ArrowHead/PAM-MSM/",
43+
_TEST_RESULTS_PATH + "/clustering/PAM-DTW/Predictions/ArrowHead/",
44+
_TEST_RESULTS_PATH + "/clustering/PAM-ERP/Predictions/ArrowHead/",
45+
_TEST_RESULTS_PATH + "/clustering/PAM-MSM/Predictions/ArrowHead/",
4946
]
5047

51-
ivc = FromFileIterativeVotingClustering(clusterers=file_paths, n_clusters=3, max_iterations=100, random_state=0)
48+
ivc = FromFileIterativeVotingClustering(
49+
clusterers=file_paths, n_clusters=3, max_iterations=100, random_state=0
50+
)
5251
ivc.fit(X_train, y_train)
5352
preds = ivc.predict(X_test)
5453

0 commit comments

Comments
 (0)