@File : init.py @Time : 2024/06/07 13:56:21 @Author : Alejandro Marrero @Version : 1.0 @Contact : amarrerd@ull.edu.es @License : (C)Copyright 2024, Alejandro Marrero @Desc : None

SupportsTransform

Bases: Protocol

Protocol to type check all the transformer types in digneapy. A Transformer is any callable type that receives a sequence and transforms it to other sequence.

Source code in digneapy/transformers/_base.py
20
21
22
23
24
25
26
class SupportsTransform(Protocol):
    """Protocol to type check all the transformer types in digneapy.
    A Transformer is any callable type that receives a sequence and transforms it
    to other sequence.
    """

    def __call__(self, x: npt.NDArray) -> np.ndarray: ...

Transformer

Bases: ABC, SupportsTransform

Transformer is any callable type that receives a sequence and transforms it to other sequence. Ussually, the transformer is a model that is trained to transform the input data to a new space. The transformer is a subclass of the SupportsTransform protocol.

Source code in digneapy/transformers/_base.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class Transformer(ABC, SupportsTransform):
    """Transformer is any callable type that receives a sequence and transforms it
    to other sequence. Ussually, the transformer is a model that is trained to transform
    the input data to a new space. The transformer is a subclass of the SupportsTransform
    protocol.
    """

    def __init__(self, name: str):
        self._name = name

    def train(self, x: npt.NDArray):
        raise NotImplementedError("train method not implemented in Transformer")

    def predict(self, x: npt.NDArray) -> np.ndarray:
        raise NotImplementedError("predict method not implemented in Transformer")

    @abstractmethod
    def __call__(self, x: npt.NDArray) -> np.ndarray:
        raise NotImplementedError("__call__ method not implemented in Transformer")

    def save(self):
        raise NotImplementedError("save method not implemented in Transformer")