mirror of
https://github.com/webclinic017/drift.git
synced 2026-07-27 18:57:55 +00:00
feat(Transformations): added robust scaler (#223)
* feat(Transformations): added robust scaler * fix(Config): set back default scaler to MinMax
This commit is contained in:
committed by
GitHub
parent
229f16c4b3
commit
7a443d93e4
+2
-2
@@ -15,10 +15,10 @@ def get_default_config() -> RawConfig:
|
||||
|
||||
return RawConfig(
|
||||
dimensionality_reduction_ratio=0.5,
|
||||
n_features_to_select=30,
|
||||
n_features_to_select=50,
|
||||
sliding_window_size=3800,
|
||||
retrain_every=1000,
|
||||
scaler="minmax", # 'normalize' 'minmax' 'standardize'
|
||||
scaler="minmax", # 'normalize' 'minmax' 'standardize' 'robust'
|
||||
assets=["fivemin_crypto"],
|
||||
target_asset="BTC_USD",
|
||||
other_assets=[],
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ from typing import Literal, Optional
|
||||
from labeling.types import EventFilter
|
||||
from models.base import Model
|
||||
from data_loader.types import DataCollection, DataSource
|
||||
from feature_extractors.types import FeatureExtractor, ScalerTypes
|
||||
from feature_extractors.types import FeatureExtractor
|
||||
from labeling.types import EventFilter, EventLabeller
|
||||
from sklearn.base import BaseEstimator
|
||||
from dataclasses import dataclass
|
||||
@@ -15,7 +15,7 @@ class RawConfig(BaseModel):
|
||||
n_features_to_select: int
|
||||
sliding_window_size: int
|
||||
retrain_every: int
|
||||
scaler: Literal["normalize", "minmax", "standardize"]
|
||||
scaler: Literal["normalize", "minmax", "standardize", "robust"]
|
||||
|
||||
assets: list[str]
|
||||
target_asset: str
|
||||
|
||||
@@ -16,10 +16,6 @@ def get_crypto_price_crypto_compare(
|
||||
return df
|
||||
|
||||
|
||||
ada = get_crypto_price_crypto_compare("ADA", "USD", 1500)
|
||||
ada
|
||||
|
||||
|
||||
def get_crypto_price_av(symbol: str, exchange: str, start_date=None) -> pd.DataFrame:
|
||||
api_url = f"https://www.alphavantage.co/query?function=DIGITAL_CURRENCY_DAILY&symbol={symbol}&market={exchange}&apikey={AV_API_KEY}"
|
||||
raw_df = requests.get(api_url).json()
|
||||
|
||||
@@ -6,4 +6,3 @@ IsLogReturn = bool
|
||||
FeatureExtractor = Callable[[pd.DataFrame, Period], Union[pd.DataFrame, pd.Series]]
|
||||
Name = str
|
||||
FeatureExtractorConfig = tuple[Name, FeatureExtractor, list[Period]]
|
||||
ScalerTypes = Literal["normalize", "minmax", "standardize", "none"]
|
||||
|
||||
@@ -3,9 +3,9 @@ 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
|
||||
from sklearn.preprocessing import MinMaxScaler, Normalizer, StandardScaler, RobustScaler
|
||||
|
||||
ScalerTypes = Literal["normalize", "minmax", "standardize"]
|
||||
ScalerTypes = Literal["normalize", "minmax", "standardize", "robust"]
|
||||
|
||||
|
||||
def get_rfe(n_feature_to_select: int) -> Optional[RFETransformation]:
|
||||
@@ -38,5 +38,9 @@ def get_scaler(type: ScalerTypes) -> SKLearnTransformation:
|
||||
return SKLearnTransformation(MinMaxScaler(feature_range=(-1, 1)))
|
||||
elif type == "standardize":
|
||||
return SKLearnTransformation(StandardScaler())
|
||||
elif type == "robust":
|
||||
return SKLearnTransformation(
|
||||
RobustScaler(with_centering=False, quantile_range=(0.10, 0.90))
|
||||
)
|
||||
else:
|
||||
raise Exception("Scaler type not supported")
|
||||
|
||||
Reference in New Issue
Block a user