Skip to content

Instantly share code, notes, and snippets.

@mprzybyla123
Created July 21, 2020 21:01
Show Gist options
  • Save mprzybyla123/aa535638020080a729aab180b4c60f66 to your computer and use it in GitHub Desktop.
Save mprzybyla123/aa535638020080a729aab180b4c60f66 to your computer and use it in GitHub Desktop.
classes
# text and numeric classes that use sklearn base libaries
class TextTransformer(BaseEstimator, TransformerMixin):
"""
Transform text features
"""
def __init__(self, key):
self.key = key
def fit(self, X, y=None, *parg, **kwarg):
return self
def transform(self, X):
return X[self.key]
class NumberTransformer(BaseEstimator, TransformerMixin):
"""
Transform numeric features
"""
def __init__(self, key):
self.key = key
def fit(self, X, y=None):
return self
def transform(self, X):
return X[[self.key]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment