from abc import ABC, abstractmethod
import numpy as np
from typing import Any
from ..node import CubeConsumer, LabelConsumer
[docs]
class Preprocessor(ABC, CubeConsumer):
"""
Abstract class for data preprocessing.
"""
[docs]
@abstractmethod
def fit(self, X):
"""
Fit the preprocessor to the data.
Parameters
----------
X : array-like
Input data.
Returns
-------
self
"""
pass
[docs]
@abstractmethod
def forward(self, X):
pass
[docs]
class BaseSupervised(ABC, CubeConsumer, LabelConsumer):
[docs]
@abstractmethod
def fit(self, X, Y):
pass
[docs]
@abstractmethod
def forward(self, X):
pass
[docs]
class BaseUnsupervised(ABC, CubeConsumer):
"""Abstract node for all unsupervised classifiers to follow.
Parameters
----------
ABC : ABC
Defines node as a base class.
"""
[docs]
@abstractmethod
def fit(self, X: Any):
"""_summary_
Parameters
----------
X : Any
Generic method to initialize a classifier with data.
"""
pass
[docs]
@abstractmethod
def forward(self, Any) -> Any:
"""Transform
Parameters
----------
X : Any
Generic method to pass new data through the unsupervised classifier.
Returns
-------
Any
Return type and shape must be defined by the implemented child classes.
"""
pass