Skip to content

Commit 99eff75

Browse files
committed
fix TheilSenRegressor input validation, LassoLarsIC input validation
1 parent 2afbc0f commit 99eff75

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

sklearn/linear_model/least_angle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ def fit(self, X, y, copy_X=True):
12951295
returns an instance of self.
12961296
"""
12971297
self.fit_path = True
1298-
X, y = check_X_y(X, y, multi_output=True, y_numeric=True)
1298+
X, y = check_X_y(X, y, y_numeric=True)
12991299

13001300
X, y, Xmean, ymean, Xstd = LinearModel._center_data(
13011301
X, y, self.fit_intercept, self.normalize, self.copy_X)

sklearn/linear_model/theil_sen.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
from .base import LinearModel
2121
from ..base import RegressorMixin
22-
from ..utils import check_array, check_random_state, ConvergenceWarning
23-
from ..utils import check_consistent_length, _get_n_jobs
22+
from ..utils import check_random_state, ConvergenceWarning
23+
from ..utils import check_X_y, _get_n_jobs
2424
from ..utils.random import choice
2525
from ..externals.joblib import Parallel, delayed
2626
from ..externals.six.moves import xrange as range
@@ -343,9 +343,7 @@ def fit(self, X, y):
343343
self : returns an instance of self.
344344
"""
345345
random_state = check_random_state(self.random_state)
346-
X = check_array(X)
347-
y = check_array(y, ensure_2d=False)
348-
check_consistent_length(X, y)
346+
X, y = check_X_y(X, y, y_numeric=True)
349347
n_samples, n_features = X.shape
350348
n_subsamples, self.n_subpopulation_ = self._check_subparams(n_samples,
351349
n_features)

sklearn/utils/estimator_checks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ def check_estimators_unfitted(name, Estimator):
841841

842842
def check_supervised_y_2d(name, Estimator):
843843
if "MultiTask" in name:
844-
# These only work on 2d, this test makes not sense
844+
# These only work on 2d, so this test makes no sense
845845
return
846846
rnd = np.random.RandomState(0)
847847
X = rnd.uniform(size=(10, 3))
@@ -866,9 +866,9 @@ def check_supervised_y_2d(name, Estimator):
866866
msg = "expected 1 DataConversionWarning, got: %s" % (
867867
", ".join([str(w_x) for w_x in w]))
868868
if name not in MULTI_OUTPUT:
869-
# warned if we don't support multi-output
869+
# check that we warned if we don't support multi-output
870870
assert_equal(len(w), 1, msg)
871-
assert_array_equal(y_pred.ravel(), y_pred_2d.ravel())
871+
assert_array_almost_equal(y_pred.ravel(), y_pred_2d.ravel())
872872

873873

874874
def check_classifiers_classes(name, Classifier):

0 commit comments

Comments
 (0)