mirror of
https://github.com/webclinic017/drift.git
synced 2026-08-16 12:28:09 +00:00
fix(Pipeline): remove PCA step that introduced clear lookahead bias (#164)
This commit is contained in:
@@ -10,7 +10,7 @@ from reporting.types import Reporting
|
||||
|
||||
def train_meta_labeling_model(
|
||||
target_asset: str,
|
||||
X_pca: pd.DataFrame,
|
||||
X: pd.DataFrame,
|
||||
input_predictions: pd.Series,
|
||||
y: pd.Series,
|
||||
target_returns: pd.Series,
|
||||
@@ -28,9 +28,9 @@ def train_meta_labeling_model(
|
||||
|
||||
print("Feature Selection started")
|
||||
backup_model = default_feature_selector_regression if data_config['method'] == 'regression' else default_feature_selector_classification
|
||||
meta_feature_selection_input_X, meta_feature_selection_input_y = drop_until_first_valid_index(X_pca, meta_y)
|
||||
meta_feature_selection_input_X, meta_feature_selection_input_y = drop_until_first_valid_index(X, meta_y)
|
||||
feature_selection_output = select_features(X = meta_feature_selection_input_X, y = meta_feature_selection_input_y, model = models[0][1], n_features_to_select = training_config['n_features_to_select'], backup_model = backup_model, scaling = training_config['scaler'])
|
||||
meta_selected_features_X = X_pca[feature_selection_output.columns]
|
||||
meta_selected_features_X = X[feature_selection_output.columns]
|
||||
|
||||
meta_X = pd.concat([meta_selected_features_X, input_predictions, discretized_predictions], axis = 1)
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ def primary_step(
|
||||
X: pd.DataFrame,
|
||||
y:pd.Series,
|
||||
original_X:pd.DataFrame,
|
||||
X_pca:pd.DataFrame,
|
||||
asset:list,
|
||||
target_returns:pd.Series,
|
||||
configs: dict,
|
||||
@@ -46,7 +45,7 @@ def primary_step(
|
||||
primary_model_predictions = current_predictions[model_name]
|
||||
primary_meta_result, primary_meta_preds, primary_meta_probabilities, meta_labeling_models = train_meta_labeling_model(
|
||||
target_asset=asset[1],
|
||||
X_pca = X_pca,
|
||||
X = original_X,
|
||||
input_predictions= primary_model_predictions,
|
||||
y = y,
|
||||
target_returns = target_returns,
|
||||
@@ -73,7 +72,6 @@ def secondary_step(
|
||||
X:pd.DataFrame,
|
||||
y:pd.Series,
|
||||
original_X:pd.DataFrame,
|
||||
X_pca:pd.DataFrame,
|
||||
current_predictions:pd.DataFrame,
|
||||
asset:list,
|
||||
target_returns:pd.Series,
|
||||
@@ -114,7 +112,7 @@ def secondary_step(
|
||||
# 3. Train a Meta-labeling model on the averaged level-1 model predictions
|
||||
ensemble_meta_result, ensemble_meta_predictions, ensemble_meta_probabilities, ensemble_meta_labeling_models = train_meta_labeling_model(
|
||||
target_asset=asset[1],
|
||||
X_pca = X_pca,
|
||||
X = original_X,
|
||||
input_predictions= ensemble_predictions,
|
||||
y = y,
|
||||
target_returns = target_returns,
|
||||
|
||||
Reference in New Issue
Block a user