MCPcopy
hub / github.com/scikit-learn/scikit-learn / _check_y

Function _check_y

sklearn/utils/validation.py:1351–1371  ·  view source on GitHub ↗

Isolated part of check_X_y dedicated to y validation

(y, multi_output=False, y_numeric=False, estimator=None)

Source from the content-addressed store, hash-verified

1349
1350
1351def _check_y(y, multi_output=False, y_numeric=False, estimator=None):
1352 """Isolated part of check_X_y dedicated to y validation"""
1353 if multi_output:
1354 y = check_array(
1355 y,
1356 accept_sparse="csr",
1357 ensure_all_finite=True,
1358 ensure_2d=False,
1359 dtype=None,
1360 input_name="y",
1361 estimator=estimator,
1362 )
1363 else:
1364 estimator_name = _check_estimator_name(estimator)
1365 y = column_or_1d(y, warn=True)
1366 _assert_all_finite(y, input_name="y", estimator_name=estimator_name)
1367 _ensure_no_complex_data(y)
1368 if y_numeric and hasattr(y.dtype, "kind") and y.dtype.kind == "O":
1369 y = y.astype(np.float64)
1370
1371 return y
1372
1373
1374def column_or_1d(y, *, dtype=None, input_name="y", warn=False, device=None):

Callers 5

_fit_encodings_allMethod · 0.90
fitMethod · 0.90
check_X_yFunction · 0.85
validate_dataFunction · 0.85

Calls 5

check_arrayFunction · 0.85
_check_estimator_nameFunction · 0.85
column_or_1dFunction · 0.85
_assert_all_finiteFunction · 0.85
_ensure_no_complex_dataFunction · 0.85

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…