Skip to content

Commit b29a54c

Browse files
author
Michal Romaniuk
committed
Repaired some of the damage caused by rebasing.
1 parent 2b96b10 commit b29a54c

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed

doc/whats_new.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Enhancements
5353
parameter. This does not affect errors raised on re-fit. By
5454
`Michal Romaniuk`_.
5555

56+
5657
Documentation improvements
5758
..........................
5859

sklearn/grid_search.py

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from .externals.joblib import Parallel, delayed
2626
from .externals import six
2727
from .utils import check_random_state
28-
from .utils.validation import _num_samples, check_arrays
28+
from .utils.validation import _num_samples, indexable
2929
from .metrics.scorer import check_scoring
3030

3131

@@ -282,15 +282,13 @@ class BaseSearchCV(six.with_metaclass(ABCMeta, BaseEstimator,
282282
"""Base class for hyper parameter search with cross-validation."""
283283

284284
@abstractmethod
285-
def __init__(self, estimator, scoring=None, loss_func=None,
286-
score_func=None, fit_params=None, n_jobs=1, iid=True,
285+
def __init__(self, estimator, scoring=None,
286+
fit_params=None, n_jobs=1, iid=True,
287287
refit=True, cv=None, verbose=0, pre_dispatch='2*n_jobs',
288288
error_score='raise'):
289289

290290
self.scoring = scoring
291291
self.estimator = estimator
292-
self.loss_func = loss_func
293-
self.score_func = score_func
294292
self.n_jobs = n_jobs
295293
self.fit_params = fit_params if fit_params is not None else {}
296294
self.iid = iid
@@ -349,20 +347,16 @@ def _fit(self, X, y, parameter_iterable):
349347

350348
estimator = self.estimator
351349
cv = self.cv
352-
self.scorer_ = check_scoring(self.estimator, scoring=self.scoring,
353-
loss_func=self.loss_func,
354-
score_func=self.score_func)
350+
self.scorer_ = check_scoring(self.estimator, scoring=self.scoring)
355351

356352
n_samples = _num_samples(X)
357-
X, y = check_arrays(X, y, allow_lists=True, sparse_format='csr',
358-
allow_nans=True)
353+
X, y = indexable(X, y)
359354

360355
if y is not None:
361356
if len(y) != n_samples:
362357
raise ValueError('Target variable (y) has a different number '
363358
'of samples (%i) than data (X: %i samples)'
364359
% (len(y), n_samples))
365-
y = np.asarray(y)
366360
cv = check_cv(cv, X, y, classifier=is_classifier(estimator))
367361

368362
if self.verbose > 0:
@@ -525,14 +519,14 @@ class GridSearchCV(BaseSearchCV):
525519
degree=..., gamma=..., kernel='rbf', max_iter=-1,
526520
probability=False, random_state=None, shrinking=True,
527521
tol=..., verbose=False),
528-
fit_params={}, iid=..., loss_func=..., n_jobs=1, param_grid=...,
529-
pre_dispatch=..., refit=..., score_func=..., scoring=...,
530-
verbose=...)
522+
fit_params={}, iid=..., n_jobs=1,
523+
param_grid=..., pre_dispatch=..., refit=...,
524+
scoring=..., verbose=...)
531525
532526
533527
Attributes
534528
----------
535-
`grid_scores_` : list of named tuples
529+
grid_scores_ : list of named tuples
536530
Contains scores for all parameter combinations in param_grid.
537531
Each entry corresponds to one parameter setting.
538532
Each named tuple has the attributes:
@@ -542,18 +536,18 @@ class GridSearchCV(BaseSearchCV):
542536
cross-validation folds
543537
* ``cv_validation_scores``, the list of scores for each fold
544538
545-
`best_estimator_` : estimator
539+
best_estimator_ : estimator
546540
Estimator that was chosen by the search, i.e. estimator
547541
which gave highest score (or smallest loss if specified)
548542
on the left out data.
549543
550-
`best_score_` : float
544+
best_score_ : float
551545
Score of best_estimator on the left out data.
552546
553-
`best_params_` : dict
547+
best_params_ : dict
554548
Parameter setting that gave the best results on the hold out data.
555549
556-
`scorer_` : function
550+
scorer_ : function
557551
Scorer function used on the held out data to choose the best
558552
parameters for the model.
559553
@@ -591,7 +585,7 @@ def __init__(self, estimator, param_grid, scoring=None, loss_func=None,
591585
error_score='raise'):
592586

593587
super(GridSearchCV, self).__init__(
594-
estimator, scoring, loss_func, score_func, fit_params, n_jobs, iid,
588+
estimator, scoring, fit_params, n_jobs, iid,
595589
refit, cv, verbose, pre_dispatch, error_score)
596590
self.param_grid = param_grid
597591
_check_param_grid(param_grid)
@@ -696,7 +690,7 @@ class RandomizedSearchCV(BaseSearchCV):
696690
697691
Attributes
698692
----------
699-
`grid_scores_` : list of named tuples
693+
grid_scores_ : list of named tuples
700694
Contains scores for all parameter combinations in param_grid.
701695
Each entry corresponds to one parameter setting.
702696
Each named tuple has the attributes:
@@ -706,15 +700,15 @@ class RandomizedSearchCV(BaseSearchCV):
706700
cross-validation folds
707701
* ``cv_validation_scores``, the list of scores for each fold
708702
709-
`best_estimator_` : estimator
703+
best_estimator_ : estimator
710704
Estimator that was chosen by the search, i.e. estimator
711705
which gave highest score (or smallest loss if specified)
712706
on the left out data.
713707
714-
`best_score_` : float
708+
best_score_ : float
715709
Score of best_estimator on the left out data.
716710
717-
`best_params_` : dict
711+
best_params_ : dict
718712
Parameter setting that gave the best results on the hold out data.
719713
720714
Notes

0 commit comments

Comments
 (0)