I've written a wrapper class around some machine learning models (from sklearn) but I want to expose the underlying model attributes and methods directly for compatibility with other code.
As a toy example...
class LogWrapper(BaseEstimator):
def __init__(self, model):
self.model = model
def fit(self, X, y):
y_log = np.log(y)
self.model.fit(X, y_log)
def predict(self, X):
y_log_pred = self.model.predict(X)
y_pred = np.exp(y_log_pred)
return y_pred
# Then you can do
my_model = LogWrapper(DecisionTreeRegressor(max_depth=4))
However, I would like to access the model
's methods without having to write code of the form
my_model.model.decision_path(X)
I'd prefer to write
my_model.decision_path(X)
The desired behaviour is comparable to having the LogWrapper
class inherit from the class of model
passed to the init rather than from BaseEstimator.