2022-01-04 11:44:35 +01:00
|
|
|
from sklearn.preprocessing import MinMaxScaler, Normalizer, StandardScaler
|
2022-01-26 23:22:43 +01:00
|
|
|
from .sklearn import SKLearnTransformation
|
|
|
|
|
from typing import Literal
|
|
|
|
|
|
|
|
|
|
ScalerTypes = Literal['normalize', 'minmax', 'standardize']
|
2022-01-04 11:44:35 +01:00
|
|
|
|
2022-01-12 23:22:55 +01:00
|
|
|
def get_scaler(type: ScalerTypes) -> SKLearnTransformation:
|
2022-01-04 11:44:35 +01:00
|
|
|
if type == 'normalize':
|
2022-01-12 23:22:55 +01:00
|
|
|
return SKLearnTransformation(Normalizer())
|
2022-01-04 11:44:35 +01:00
|
|
|
elif type == 'minmax':
|
2022-01-12 23:22:55 +01:00
|
|
|
return SKLearnTransformation(MinMaxScaler(feature_range= (-1, 1)))
|
2022-01-04 11:44:35 +01:00
|
|
|
elif type == 'standardize':
|
2022-01-12 23:22:55 +01:00
|
|
|
return SKLearnTransformation(StandardScaler())
|
2022-01-04 11:44:35 +01:00
|
|
|
else:
|
2022-01-12 14:42:16 +01:00
|
|
|
raise Exception("Scaler type not supported")
|