Label Transforms
transforms.Select
- class torcheeg.transforms.Select(key: Union[str, List])[source]
Bases:
object
Select part of the value from the information dictionary.
transform = Select(key='valence') transform({'valence': 4.5, 'arousal': 5.5, 'subject': 7}) >>> 4.5
Select
allows multiple values to be selected and returned as a list. Suitable for multi-classification tasks or multi-task learning.transform = Select(key=['valence', 'arousal']) transform({'valence': 4.5, 'arousal': 5.5, 'subject': 7}) >>> [4.5, 5.5]
- Parameters
key (str or list) – The selected key can be a key string or a list of keys.
transforms.Binary
- class torcheeg.transforms.Binary(threshold: float)[source]
Bases:
object
Binarize the label according to a certain threshold. Labels larger than the threshold are set to 1, and labels smaller than the threshold are set to 0.
transform = Binary(threshold=5.0) transform(4.5) >>> 0
Binary
allows simultaneous binarization using the same threshold for multiple labels.transform = Binary(threshold=5.0) transform([4.5, 5.5]) >>> [0, 1]
- Parameters
threshold (float) – Threshold used during binarization.
transforms.BinariesToCategory
- class torcheeg.transforms.BinariesToCategory[source]
Bases:
object
Convert multiple binary labels into one multiclass label. Multiclass labels represent permutations of binary labels. Commonly used to combine two binary classification tasks into a single quad classification task.
transform = BinariesToCategory() transform([0, 0]) >>> 0 transform([0, 1]) >>> 1 transform([1, 0]) >>> 2 transform([1, 1]) >>> 3