Skip to content

Commit

Permalink
fix sklearn best score
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen committed Jul 30, 2015
1 parent c261b3d commit 5f9f422
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions wrapper/xgboost.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ def train(params, dtrain, num_boost_round=10, evals=(), obj=None, feval=None,
bst.best_iteration = best_score_i
return bst


class CVPack(object):
""""Auxiliary datastruct to hold one fold of CV."""
def __init__(self, dtrain, dtest, param):
Expand Down Expand Up @@ -1154,9 +1155,11 @@ def fit(self, X, y, eval_set=None, eval_metric=None,
eval_results = {k: np.array(v, dtype=float)
for k, v in eval_results.items()}
eval_results = {k: np.array(v) for k, v in eval_results.items()}
self.eval_results_ = eval_results
self.best_score_ = self._Booster.best_score
self.best_iteration_ = self._Booster.best_iteration
self.eval_results = eval_results

if early_stopping_rounds is not None:
self.best_score = self._Booster.best_score
self.best_iteration = self._Booster.best_iteration
return self

def predict(self, data):
Expand Down Expand Up @@ -1266,9 +1269,11 @@ def fit(self, X, y, sample_weight=None, eval_set=None, eval_metric=None,
if eval_results:
eval_results = {k: np.array(v, dtype=float)
for k, v in eval_results.items()}
self.eval_results_ = eval_results
self.best_score_ = self._Booster.best_score
self.best_iteration_ = self._Booster.best_iteration
self.eval_results = eval_results

if early_stopping_rounds is not None:
self.best_score = self._Booster.best_score
self.best_iteration = self._Booster.best_iteration

return self

Expand Down

0 comments on commit 5f9f422

Please sign in to comment.