Isolated part of check_X_y dedicated to y validation
(y, multi_output=False, y_numeric=False, estimator=None)
| 1349 | |
| 1350 | |
| 1351 | def _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 | |
| 1374 | def column_or_1d(y, *, dtype=None, input_name="y", warn=False, device=None): |
searching dependent graphs…