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

Function validate_data

sklearn/utils/validation.py:2929–3061  ·  view source on GitHub ↗

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`. .. versionadd

(
    _estimator,
    /,
    X="no_validation",
    y="no_validation",
    reset=True,
    validate_separately=False,
    skip_check_array=False,
    **check_params,
)

Source from the content-addressed store, hash-verified

2927
2928
2929def validate_data(
2930 _estimator,
2931 /,
2932 X="no_validation",
2933 y="no_validation",
2934 reset=True,
2935 validate_separately=False,
2936 skip_check_array=False,
2937 **check_params,
2938):
2939 """Validate input data and set or check feature names and counts of the input.
2940
2941 This helper function should be used in an estimator that requires input
2942 validation. This mutates the estimator and sets the `n_features_in_` and
2943 `feature_names_in_` attributes if `reset=True`.
2944
2945 .. versionadded:: 1.6
2946
2947 Parameters
2948 ----------
2949 _estimator : estimator instance
2950 The estimator to validate the input for.
2951
2952 X : {array-like, sparse matrix, dataframe} of shape \
2953 (n_samples, n_features), default='no validation'
2954 The input samples.
2955 If `'no_validation'`, no validation is performed on `X`. This is
2956 useful for meta-estimator which can delegate input validation to
2957 their underlying estimator(s). In that case `y` must be passed and
2958 the only accepted `check_params` are `multi_output` and
2959 `y_numeric`.
2960
2961 y : array-like of shape (n_samples,), default='no_validation'
2962 The targets.
2963
2964 - If `None`, :func:`~sklearn.utils.check_array` is called on `X`. If
2965 the estimator's `requires_y` tag is True, then an error will be raised.
2966 - If `'no_validation'`, :func:`~sklearn.utils.check_array` is called
2967 on `X` and the estimator's `requires_y` tag is ignored. This is a default
2968 placeholder and is never meant to be explicitly set. In that case `X` must be
2969 passed.
2970 - Otherwise, only `y` with `_check_y` or both `X` and `y` are checked with
2971 either :func:`~sklearn.utils.check_array` or
2972 :func:`~sklearn.utils.check_X_y` depending on `validate_separately`.
2973
2974 reset : bool, default=True
2975 Whether to reset the `n_features_in_` attribute.
2976 If False, the input will be checked for consistency with data
2977 provided when reset was last True.
2978
2979 .. note::
2980
2981 It is recommended to call `reset=True` in `fit` and in the first
2982 call to `partial_fit`. All other methods that validate `X`
2983 should set `reset=False`.
2984
2985 validate_separately : False or tuple of dicts, default=False
2986 Only used if `y` is not `None`.

Callers 15

fitMethod · 0.90
transformMethod · 0.90
fitMethod · 0.90
transformMethod · 0.90
fitMethod · 0.90
transformMethod · 0.90
fitMethod · 0.90
transformMethod · 0.90
fitMethod · 0.90
transformMethod · 0.90
fitMethod · 0.90
predictMethod · 0.90

Calls 7

get_tagsFunction · 0.90
check_arrayFunction · 0.85
_check_yFunction · 0.85
check_X_yFunction · 0.85
_check_n_featuresFunction · 0.85
getMethod · 0.80
_check_feature_namesFunction · 0.70

Tested by 15

__init__Method · 0.72
__init__Method · 0.72
fitMethod · 0.72
fitMethod · 0.72
fitMethod · 0.72
fitMethod · 0.72
fitMethod · 0.72
fitMethod · 0.72
fitMethod · 0.72
fitMethod · 0.72
fitMethod · 0.72
fitMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…