mirror of
https://github.com/webclinic017/drift.git
synced 2026-07-27 18:57:55 +00:00
feature(Config): added transformation parameters to Config, removed expanding_window (it's ON now)
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
from .rfe import RFETransformation
|
||||
from .pca import PCATransformation
|
||||
from .sklearn import SKLearnTransformation
|
||||
from typing import Literal, Optional
|
||||
from models.model_map import default_feature_selector_classification
|
||||
from sklearn.preprocessing import MinMaxScaler, Normalizer, StandardScaler
|
||||
|
||||
ScalerTypes = Literal["normalize", "minmax", "standardize"]
|
||||
|
||||
|
||||
def get_rfe(n_feature_to_select: int) -> Optional[RFETransformation]:
|
||||
if n_feature_to_select > 0:
|
||||
return RFETransformation(
|
||||
n_feature_to_select=n_feature_to_select,
|
||||
model=default_feature_selector_classification,
|
||||
)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def get_pca(
|
||||
ratio_components_to_keep: float, sliding_window_size: int
|
||||
) -> Optional[PCATransformation]:
|
||||
|
||||
if ratio_components_to_keep > 0:
|
||||
return PCATransformation(
|
||||
ratio_components_to_keep=ratio_components_to_keep,
|
||||
sliding_window_size=sliding_window_size,
|
||||
)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def get_scaler(type: ScalerTypes) -> SKLearnTransformation:
|
||||
if type == "normalize":
|
||||
return SKLearnTransformation(Normalizer())
|
||||
elif type == "minmax":
|
||||
return SKLearnTransformation(MinMaxScaler(feature_range=(-1, 1)))
|
||||
elif type == "standardize":
|
||||
return SKLearnTransformation(StandardScaler())
|
||||
else:
|
||||
raise Exception("Scaler type not supported")
|
||||
Reference in New Issue
Block a user