def __init__(self, threshold):
    self.threshold = threshold

def fit(self, X, y):
    model = RandomForestClassifier(n_estimators=100, n_jobs=-1,
        random_state=42, oob_score=False)
model.fit(X, y)
self.model = model
return self

def transform(self, X):
    return self.model.transform(X, self.threshold)
How to gridsearch over transform arguments within a pipeline in scikit-learn