-
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
14 changed files
with
174 additions
and
44 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
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 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,25 @@ | ||
from numpy import ndarray | ||
|
||
from cpdbench.dataset.CPDDataset import CPDDataset | ||
|
||
|
||
class CPDNdarrayDataset(CPDDataset): | ||
|
||
def get_validation_preview(self) -> tuple[ndarray, list[int]]: | ||
return self._validation_array, self._validation_ground_truths | ||
|
||
def __init__(self, numpy_array, ground_truths, validation_amount=-1): | ||
self._ndarray = numpy_array | ||
self._ground_truths = ground_truths | ||
if validation_amount == -1: | ||
self._validation_array = self._ndarray[:, :] | ||
else: | ||
self._validation_array = self._ndarray[:, 0:validation_amount] | ||
validation_array_length = self._validation_array.shape[1] | ||
self._validation_ground_truths = [el for el in self._ground_truths if el < validation_array_length] | ||
|
||
def init(self) -> None: | ||
pass | ||
|
||
def get_signal(self) -> tuple[ndarray, list[int]]: | ||
return self._ndarray, self._ground_truths |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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(): | ||
raise KeyError | ||
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 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,33 @@ | ||
from time import sleep | ||
|
||
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(): | ||
sleep(10) | ||
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 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,34 @@ | ||
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_wrong(signal, window): | ||
return example_algorithms.algorithm_execute_single_esst(signal) | ||
|
||
@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 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,32 @@ | ||
from cpdbench.examples import ExampleAlgorithms | ||
from cpdbench.examples.ExampleDatasets import get_extreme_large_dataset_from_file | ||
from cpdbench.examples.ExampleMetrics import metric_accuracy_in_allowed_windows | ||
from cpdbench.CPDBench import CPDBench | ||
import pathlib | ||
|
||
cpdb = CPDBench() | ||
|
||
|
||
@cpdb.dataset | ||
def get_large_dataset(): | ||
return get_extreme_large_dataset_from_file(1000) | ||
|
||
|
||
@cpdb.algorithm | ||
def execute_algorithm(dataset): | ||
dataset = dataset.reshape((1, dataset.size)) | ||
res = ExampleAlgorithms.algorithm_execute_single_esst(dataset) | ||
assert dataset.ndim == 3 | ||
return res | ||
|
||
|
||
@cpdb.metric | ||
def compute_metric(indexes, confidences, ground_truths): | ||
return metric_accuracy_in_allowed_windows(indexes, confidences, ground_truths, window_size=20) | ||
|
||
|
||
if __name__ == '__main__': | ||
path = pathlib.Path(__file__).parent.resolve() | ||
path = path.joinpath("configs", "VeryLargeDatasetConfig.yml") | ||
#cpdb.start(config_file=str(path)) | ||
cpdb.validate(config_file=str(path)) |
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
This file was deleted.
Oops, something went wrong.