-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
124 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,8 @@ | |
src/cpdbench-log.txt | ||
src/cpdbench-result.json | ||
|
||
*.txt | ||
*.json | ||
|
||
venv | ||
venv-new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,29 @@ | ||
from changepoynt.algorithms.sst import SST | ||
|
||
|
||
def numpy_array_accesses(dataset, array_indexes): | ||
indexes = [] | ||
for i in array_indexes: | ||
indexes.append(dataset[i]) | ||
confidences = [1 for _ in range(len(indexes))] | ||
return indexes, confidences | ||
|
||
|
||
def algorithm_execute_single_esst(signal): | ||
"""Uses SST as implemented in the changepoynt library as algorithm.""" | ||
detector = SST(90, method='rsvd') | ||
sig = signal[0] | ||
res = detector.transform(sig) | ||
indexes = [res.argmax()] | ||
confidences = [1.0] | ||
return indexes, confidences | ||
|
||
|
||
def algorithm_execute_single_esst(signal, window_length): | ||
"""Uses SST as implemented in the changepoynt library as algorithm.""" | ||
detector = SST(window_length, method='rsvd') | ||
sig = signal[0] | ||
res = detector.transform(sig) | ||
indexes = [res.argmax()] | ||
confidences = [1.0] | ||
return indexes, confidences |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
import pathlib | ||
|
||
import numpy as np | ||
|
||
from cpdbench.dataset.CPD2DFromFileDataset import CPD2DFromFileDataset | ||
from cpdbench.dataset.CPD2DNdarrayDataset import CPD2DNdarrayDataset | ||
|
||
|
||
def get_extreme_large_dataset_from_file(): | ||
path = pathlib.Path(__file__).parent.resolve() | ||
path = path.joinpath("data", "very_big_numpy_file.dat") | ||
dataset = CPD2DFromFileDataset(str(path), "float32", [5, 245, 255, 256, 25]) | ||
return dataset | ||
|
||
def dataset_get_apple_dataset(): | ||
raw_data = np.load("../../../data/apple.npy") | ||
timeseries = raw_data[:, 0] | ||
reshaped_ts = np.reshape(timeseries, [1, timeseries.size]) | ||
return CPD2DNdarrayDataset(reshaped_ts, [337]) | ||
|
||
|
||
def dataset_get_bitcoin_dataset(): | ||
raw_data = np.load("../../../data/bitcoin.npy") | ||
timeseries = raw_data[:, 0] | ||
reshaped_ts = np.reshape(timeseries, [1, timeseries.size]) | ||
return CPD2DNdarrayDataset(reshaped_ts, [569]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from cpdbench.CPDBench import CPDBench | ||
import cpdbench.examples.ExampleDatasets as example_datasets | ||
import cpdbench.examples.ExampleAlgorithms as example_algorithms | ||
import cpdbench.examples.ExampleMetrics as example_metrics | ||
|
||
cpdb = CPDBench() | ||
|
||
|
||
@cpdb.dataset | ||
def get_apple_dataset(): | ||
return example_datasets.dataset_get_apple_dataset() | ||
|
||
|
||
@cpdb.dataset | ||
def get_bitcoin_dataset(): | ||
return example_datasets.dataset_get_bitcoin_dataset() | ||
|
||
|
||
@cpdb.algorithm | ||
def execute_esst_test(signal, *, window_length): | ||
return example_algorithms.algorithm_execute_single_esst(signal, window_length) | ||
|
||
|
||
@cpdb.metric | ||
def calc_accuracy(indexes, scores, ground_truth, *, window_size): | ||
return example_metrics.metric_accuracy_in_allowed_windows(indexes, scores, ground_truth, window_size=window_size) | ||
|
||
|
||
if __name__ == '__main__': | ||
cpdb.start("configs/parametersConfig.yml") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from cpdbench.CPDBench import CPDBench | ||
import cpdbench.examples.ExampleDatasets as example_datasets | ||
import cpdbench.examples.ExampleAlgorithms as example_algorithms | ||
import cpdbench.examples.ExampleMetrics as example_metrics | ||
|
||
cpdb = CPDBench() | ||
|
||
|
||
@cpdb.dataset | ||
def get_apple_dataset(): | ||
return example_datasets.dataset_get_apple_dataset() | ||
|
||
|
||
@cpdb.dataset | ||
def get_bitcoin_dataset(): | ||
return example_datasets.dataset_get_bitcoin_dataset() | ||
|
||
|
||
@cpdb.algorithm | ||
def execute_esst_test(signal): | ||
return example_algorithms.algorithm_execute_single_esst(signal) | ||
|
||
|
||
@cpdb.metric | ||
def calc_accuracy(indexes, scores, ground_truth): | ||
return example_metrics.metric_accuracy_in_allowed_windows(indexes, scores, ground_truth, window_size=25) | ||
|
||
|
||
if __name__ == '__main__': | ||
cpdb.start() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
logging: | ||
filename: cpdbench-log-parameters.txt | ||
log-level: DEBUG | ||
log-level-console: WARNING | ||
multiprocessing: True | ||
|
||
result: | ||
filename: cpdbench-result-parameters.json | ||
|
||
|
||
user: | ||
algorithm-executions: | ||
- window_length: 90 | ||
- window_length: 45 | ||
- window_length: 70 | ||
|
||
metric-executions: | ||
- window_size: 50 | ||
- window_size: 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters