2022-01-12 23:22:55 +01:00
|
|
|
from __future__ import annotations
|
|
|
|
|
from typing import Literal, Optional, Union
|
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
import pandas as pd
|
|
|
|
|
|
|
|
|
|
|
2022-02-17 19:22:17 +01:00
|
|
|
class Transformation(ABC):
|
2022-01-12 23:22:55 +01:00
|
|
|
@abstractmethod
|
|
|
|
|
def fit(self, X: pd.DataFrame, y: Optional[pd.Series]) -> None:
|
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
2022-02-17 19:22:17 +01:00
|
|
|
def fit_transform(
|
|
|
|
|
self, X: pd.DataFrame, y: Optional[pd.Series] = None
|
|
|
|
|
) -> pd.DataFrame:
|
2022-01-12 23:22:55 +01:00
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def transform(self, X: pd.DataFrame) -> pd.DataFrame:
|
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def clone(self) -> Transformation:
|
|
|
|
|
raise NotImplementedError
|
|
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
|
def get_name(self) -> str:
|
|
|
|
|
raise NotImplementedError
|