Validate input data and set or check feature names and counts of the input. This helper function should be used in an estimator that requires input validation. This mutates the estimator and sets the `n_features_in_` and `feature_names_in_` attributes if `reset=True`.
(
_estimator,
/,
X="no_validation",
y="no_validation",
reset=True,
validate_separately=False,
skip_check_array=False,
**check_params,
)
| 10 | |
| 11 | # Use a limited version pulled from sklearn 1.7 |
| 12 | def validate_data( |
| 13 | _estimator, |
| 14 | /, |
| 15 | X="no_validation", |
| 16 | y="no_validation", |
| 17 | reset=True, |
| 18 | validate_separately=False, |
| 19 | skip_check_array=False, |
| 20 | **check_params, |
| 21 | ): |
| 22 | """Validate input data and set or check feature names and counts of the input. |
| 23 | |
| 24 | This helper function should be used in an estimator that requires input |
| 25 | validation. This mutates the estimator and sets the `n_features_in_` and |
| 26 | `feature_names_in_` attributes if `reset=True`. |
| 27 | |
| 28 | .. versionadded:: 1.6 |
| 29 | |
| 30 | Parameters |
| 31 | ---------- |
| 32 | _estimator : estimator instance |
| 33 | The estimator to validate the input for. |
| 34 | |
| 35 | X : {array-like, sparse matrix, dataframe} of shape \ |
| 36 | (n_samples, n_features), default='no validation' |
| 37 | The input samples. |
| 38 | If `'no_validation'`, no validation is performed on `X`. This is |
| 39 | useful for meta-estimator which can delegate input validation to |
| 40 | their underlying estimator(s). In that case `y` must be passed and |
| 41 | the only accepted `check_params` are `multi_output` and |
| 42 | `y_numeric`. |
| 43 | |
| 44 | y : array-like of shape (n_samples,), default='no_validation' |
| 45 | The targets. |
| 46 | |
| 47 | - If `None`, :func:`~sklearn.utils.check_array` is called on `X`. If |
| 48 | the estimator's `requires_y` tag is True, then an error will be raised. |
| 49 | - If `'no_validation'`, :func:`~sklearn.utils.check_array` is called |
| 50 | on `X` and the estimator's `requires_y` tag is ignored. This is a default |
| 51 | placeholder and is never meant to be explicitly set. In that case `X` must |
| 52 | be passed. |
| 53 | - Otherwise, only `y` with `_check_y` or both `X` and `y` are checked with |
| 54 | either :func:`~sklearn.utils.check_array` or |
| 55 | :func:`~sklearn.utils.check_X_y` depending on `validate_separately`. |
| 56 | |
| 57 | reset : bool, default=True |
| 58 | Whether to reset the `n_features_in_` attribute. |
| 59 | If False, the input will be checked for consistency with data |
| 60 | provided when reset was last True. |
| 61 | |
| 62 | .. note:: |
| 63 | |
| 64 | It is recommended to call `reset=True` in `fit` and in the first |
| 65 | call to `partial_fit`. All other methods that validate `X` |
| 66 | should set `reset=False`. |
| 67 | |
| 68 | validate_separately : False or tuple of dicts, default=False |
| 69 | Only used if `y` is not `None`. |
no outgoing calls
no test coverage detected