Skip to content

Commit

Permalink
bugfix for fitting PipelineES to transformers
Browse files Browse the repository at this point in the history
  • Loading branch information
alvinthai committed Jan 4, 2018
1 parent 0729b71 commit 1b9f15f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion OrderedOVRClassifier/oovr_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ class PipelineES(Pipeline):
Modified Pipeline class that allows transformed dataset to be passed into
the 'eval_set' parameter when fitting LGBMClassifier or XGBClassifier.
'''
def _transform(self, X):
Xt = X
for name, transform in self.steps:
if hasattr(transform, 'transform'):
Xt = transform.transform(Xt)
return Xt

def fit(self, X, y=None, eval_idx=None, **fit_params):
"""Fit the model
Expand Down Expand Up @@ -75,7 +82,12 @@ def fit(self, X, y=None, eval_idx=None, **fit_params):
self : Pipeline
This estimator
"""
Xt, fit_params = self._fit(X, y, **fit_params)
if eval_idx is not None:
_, fit_params = self._fit(indexer(X, eval_idx[0][0]),
indexer(y, eval_idx[0][0]), **fit_params)
Xt = self._transform(X)
else:
Xt, fit_params = self._fit(X, y, **fit_params)

if self._final_estimator is not None:
early_stop_models = ['lightgbm.sklearn', 'xgboost.sklearn']
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
# The short X.Y version.
version = u'1.1'
# The full version, including alpha/beta/rc tags.
release = u'1.1.0'
release = u'1.1.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down

0 comments on commit 1b9f15f

Please sign in to comment.