-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENH] Parameter to transform data in experiments (#322)
* data transform option * scatter fix * fixes * tsml in extras * tsml bound * tsml bound * temp comment out tsml extras * comment xgboost * more deps * esig bound * esig bound * fixes * fixes * docs * notebook
- Loading branch information
1 parent
b317e80
commit 917504e
Showing
34 changed files
with
476 additions
and
188 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 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 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 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 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,71 @@ | ||
"""get data transformer function.""" | ||
|
||
__maintainer__ = ["MatthewMiddlehurst"] | ||
|
||
from aeon.transformations.collection import Normalizer | ||
|
||
from tsml_eval.utils.functions import str_in_nested_list | ||
|
||
transformers = [ | ||
["normalizer", "normaliser"], | ||
"padder", | ||
] | ||
|
||
|
||
def get_data_transform_by_name( | ||
transformer_names, | ||
row_normalise=False, | ||
random_state=None, | ||
n_jobs=1, | ||
): | ||
"""Return a transformers matching a given input name(s). | ||
Parameters | ||
---------- | ||
transformer_names : str or list of str | ||
String or list of strings indicating the transformer(s) to be returned. | ||
row_normalise : bool, default=False | ||
Adds a Normalizer to the front of the transformer list. | ||
random_state : int, RandomState instance or None, default=None | ||
Random seed or RandomState object to be used in the classifier if available. | ||
n_jobs: int, default=1 | ||
The number of jobs to run in parallel for both classifier ``fit`` and | ||
``predict`` if available. `-1` means using all processors. | ||
Return | ||
------ | ||
transformers : A transformer or list of transformers. | ||
The transformer(s) matching the input transformer name(s). Returns a list if | ||
more than one transformer is requested. | ||
""" | ||
if transformer_names is None and not row_normalise: | ||
return None | ||
|
||
t_list = [] | ||
if row_normalise: | ||
t_list.append(Normalizer()) | ||
|
||
if transformer_names is not None: | ||
if not isinstance(transformer_names, list): | ||
transformer_names = [transformer_names] | ||
|
||
for transformer_name in transformer_names: | ||
t = transformer_name.casefold() | ||
|
||
if str_in_nested_list(transformers, t): | ||
t_list.append(_set_transformer(t, random_state, n_jobs)) | ||
else: | ||
raise ValueError( | ||
f"UNKNOWN TRANSFORMER: {t} in get_data_transform_by_name" | ||
) | ||
|
||
return t_list if len(t_list) > 1 else t_list[0] | ||
|
||
|
||
def _set_transformer(t, random_state, n_jobs): | ||
if t == "normalizer" or t == "normaliser": | ||
return Normalizer() | ||
elif t == "padder": | ||
from aeon.transformations.collection import Padder | ||
|
||
return Padder() |
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 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
Oops, something went wrong.