Skip to content

Instantly share code, notes, and snippets.

@jmansilla
Created August 26, 2016 13:39
Show Gist options
  • Save jmansilla/79929c66e05a075a84042b8f0d7583d8 to your computer and use it in GitHub Desktop.
Save jmansilla/79929c66e05a075a84042b8f0d7583d8 to your computer and use it in GitHub Desktop.
import numpy as np
class DirectTransformer:
"""Utility for building class-like features from a single-point function, but that may need
some general configuration first (you usually override __init__ for that)
"""
def fit(self, X, y=None):
return self
def transform(self, X):
return np.array([self.transform_one(x) for x in X]).reshape((-1, 1))
def transform_one(self, x):
raise NotImplementedError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment