Created
August 30, 2022 19:43
-
-
Save joshreini1/1c3cb3a733a1cd1f81f937c8f150f009 to your computer and use it in GitHub Desktop.
Transformer to prevent column leakage of test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class comprehensive_features_custom(BaseEstimator, TransformerMixin): | |
def __init__(self, comprehensive_features): | |
self.comprehensive_features = comprehensive_features | |
def fit(self, X, y = None): | |
return self | |
def transform(self, X): | |
X_post = X.reindex(labels=comprehensive_features, axis=1) | |
return X_post | |
set_comprehensive_features = comprehensive_features_custom(comprehensive_features) | |
#comprehensive preprocessing pipe | |
comprehensive_preprocessing = Pipeline([ | |
('combined_preprocessing',combined_preprocessing), | |
('set_comprehensive_features',set_comprehensive_features) | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment