mirror of
https://github.com/webclinic017/drift.git
synced 2026-08-05 15:17:46 +00:00
feat(Project): use SKLearn models directly, removed custom ensembling, use 5 minute data, batch inference, numba cusum filter (#192)
* feat(Project): use 5 minute data, running training in parallel, sped up cusum filter by 10x with numba * fix(WalkForward): inference mini-batch parallelization * fix(WalkForward): don't use the parallel version of any of the functions * feat(CI): download the data required * fix(Project): 5min_crypto folder added * fix(Evaluate): make sure we have numerical stability in returns * feat(Models): use SKLearn models directly to enable composability * feat(Inference): batched inference now working, added forecasting_horizon * fix(Inference): works again * fix(Inference) * chore(Models): remove unused Ensemble model * fix(Labeller): don't just forward shift returns, also take the sum of the data happened until then * Update test.yml
This commit is contained in:
committed by
GitHub
parent
5c94af8b01
commit
9d47ee942d
@@ -4,6 +4,7 @@ import pandas as pd
|
||||
from training.walk_forward import walk_forward_train, walk_forward_inference
|
||||
from models.base import Model
|
||||
from utils.evaluate import evaluate_predictions
|
||||
from sklearn.base import BaseEstimator, ClassifierMixin
|
||||
|
||||
no_of_rows = 100
|
||||
|
||||
@@ -29,7 +30,8 @@ def __generate_even_odd_test_data(no_of_rows) -> tuple[pd.DataFrame, pd.Series]:
|
||||
|
||||
return X, y
|
||||
|
||||
class EvenOddStubModel(Model):
|
||||
|
||||
class EvenOddStubModel(BaseEstimator, ClassifierMixin, Model):
|
||||
'''
|
||||
A deteministic model that can predict the future with 100% accuracy
|
||||
It verifies that the X[n][any_column] == 1 if n is even,
|
||||
@@ -49,14 +51,10 @@ class EvenOddStubModel(Model):
|
||||
assert y[i] == -1 if X[i][0] == 1 else 1
|
||||
|
||||
def predict(self, X):
|
||||
return (-1 if X[0][0] == 1 else 1, np.array([]))
|
||||
return np.array([-1 if row[0] == 1 else 1 for row in X])
|
||||
|
||||
def clone(self):
|
||||
return self
|
||||
|
||||
|
||||
def initialize_network(self, input_dim: int, output_dim: int):
|
||||
pass
|
||||
def predict_proba(self, X):
|
||||
return np.array([[row[0] + 1, 0] for row in X])
|
||||
|
||||
|
||||
def test_evaluation():
|
||||
|
||||
@@ -2,6 +2,7 @@ import numpy as np
|
||||
import pandas as pd
|
||||
from training.walk_forward import walk_forward_train, walk_forward_inference
|
||||
from models.base import Model
|
||||
from sklearn.base import BaseEstimator, ClassifierMixin
|
||||
|
||||
no_of_rows = 100
|
||||
|
||||
@@ -27,7 +28,7 @@ def __generate_incremental_test_data(no_of_rows) -> tuple[pd.DataFrame, pd.Serie
|
||||
|
||||
|
||||
|
||||
class IncrementingStubModel(Model):
|
||||
class IncrementingStubModel(Model, BaseEstimator, ClassifierMixin):
|
||||
'''
|
||||
A deteministic model that can predict the future with 100% accuracy
|
||||
It verifies that the X[n][any_column]+1 == y[n]
|
||||
@@ -48,13 +49,10 @@ class IncrementingStubModel(Model):
|
||||
assert X[i][0] + 1 == y[i]
|
||||
|
||||
def predict(self, X):
|
||||
return (X[0][0] + 1, np.array([]))
|
||||
return np.array([row[0] + 1 for row in X])
|
||||
|
||||
def clone(self):
|
||||
return self
|
||||
|
||||
def initialize_network(self, input_dim: int, output_dim: int):
|
||||
pass
|
||||
def predict_proba(self, X):
|
||||
return np.array([[row[0] + 1, 0] for row in X])
|
||||
|
||||
def test_walk_forward_train_test():
|
||||
X, y = __generate_incremental_test_data(no_of_rows)
|
||||
|
||||
Reference in New Issue
Block a user