mirror of
https://github.com/webclinic017/drift.git
synced 2026-08-16 04:18:07 +00:00
feat(Transformations): replaced feature selection pre-processing step with online version (with cache) (#170)
* feat(Transformations): removed feature-selection pre-processing step completely * fix(Core): removed unnecessary `original_X` * fix(Transformations): use the X_expanding_window to transform subsequent data * fix(RFE): should check for model correctly * fix(Config): only re-train the model every 40 timestamp * fix(MetaLabeling): pass in the correct X to meta-labeling step * fix(Transformation): PCA should at least keep as many features as sliding_window_size * feat(Transformations): cache transformations across the same asset * fix(Tests): missing preloaded_transformations arg * chore(Config): got rid of unnecessary 'classification_models' and 'regression_models' dictionary keys
This commit is contained in:
+5
-3
@@ -1,4 +1,5 @@
|
||||
from __future__ import annotations
|
||||
from typing import Literal
|
||||
from models.base import Model
|
||||
import numpy as np
|
||||
from sklearn.base import clone
|
||||
@@ -6,14 +7,15 @@ from sklearn.base import clone
|
||||
|
||||
class SKLearnModel(Model):
|
||||
|
||||
method: Literal["regression", "classification"]
|
||||
data_transformation = 'transformed'
|
||||
only_column = None
|
||||
feature_selection = 'on'
|
||||
model_type = 'ml'
|
||||
predict_window_size = 'single_timestamp'
|
||||
|
||||
def __init__(self, model):
|
||||
def __init__(self, model, method: Literal['regression', 'classification']):
|
||||
self.model = model
|
||||
self.method = method
|
||||
|
||||
def fit(self, X: np.ndarray, y: np.ndarray) -> None:
|
||||
self.model.fit(X, y)
|
||||
@@ -24,7 +26,7 @@ class SKLearnModel(Model):
|
||||
return (pred, probability)
|
||||
|
||||
def clone(self) -> SKLearnModel:
|
||||
return SKLearnModel(clone(self.model))
|
||||
return SKLearnModel(clone(self.model), self.method)
|
||||
|
||||
def get_name(self) -> str:
|
||||
return self.model.__class__.__name__
|
||||
|
||||
Reference in New Issue
Block a user