-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy patheasy-example-experiment.py
50 lines (40 loc) · 1.54 KB
/
easy-example-experiment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
from pathlib import Path
from timeeval import TimeEval, DatasetManager, DefaultMetrics, Algorithm, TrainingType, InputDimensionality
from timeeval.adapters import DockerAdapter, FunctionAdapter
from timeeval.params import FixedParameters
from timeeval.data_types import AlgorithmParameter
import numpy as np
def your_algorithm_function(data: AlgorithmParameter, args: dict) -> np.ndarray:
if isinstance(data, np.ndarray):
return np.zeros_like(data)
else: # data = pathlib.Path
return np.genfromtxt(data)[0]
def main():
dm = DatasetManager(Path("tests/example_data")) # or test-cases directory
datasets = dm.select()
algorithms = [
Algorithm(
name="COF",
main=DockerAdapter(image_name="registry.gitlab.hpi.de/akita/i/cof", skip_pull=True),
param_config=FixedParameters({
"n_neighbors": 20,
"random_state": 42
}),
data_as_file=True,
training_type=TrainingType.UNSUPERVISED,
input_dimensionality=InputDimensionality("multivariate")
),
Algorithm(
name="MyPythonFunctionAlgorithm",
main=FunctionAdapter(your_algorithm_function),
data_as_file=False
)
]
timeeval = TimeEval(dm, datasets, algorithms,
metrics=[DefaultMetrics.ROC_AUC, DefaultMetrics.RANGE_PR_AUC])
timeeval.run()
results = timeeval.get_results(aggregated=False)
print(results)
if __name__ == "__main__":
main()