API move BaseEstimator._validate_data to utils.validation.validate_data#29696
Conversation
There was a problem hiding this comment.
I'm still uncertain about the naming of the function that does not reflect the mutation of estimator. validate_data_and_set_estimator will be an annoying name :)
I assume that we don't have an easy way to decoupled the data validation from the estimator mutation?
|
@adam2392 @Charlie-XIAO @OmarManzoor this should be a relatively easy one to review. |
There was a problem hiding this comment.
This LGTM, thanks @adrinjalali.
We may want to add an entry in doc/api_reference.py to reveal this public API in the docs (then I may review the rendering of the docstring).
Charlie-XIAO
left a comment
There was a problem hiding this comment.
Thanks @adrinjalali, here are some minor fixes to the docstring.
| Only used if y is not None. | ||
| If False, call validate_X_y(). Else, it must be a tuple of kwargs | ||
| to be used for calling check_array() on X and y respectively. |
There was a problem hiding this comment.
| Only used if y is not None. | |
| If False, call validate_X_y(). Else, it must be a tuple of kwargs | |
| to be used for calling check_array() on X and y respectively. | |
| Only used if `y` is not `None`. | |
| If `False`, call `validate_X_y()`. Else, it must be a tuple of kwargs | |
| to be used for calling `check_array` on `X` and `y` respectively. |
There was a problem hiding this comment.
Is validate_X_y even a function within sklearn anymore? I can't find it anywhere.
There was a problem hiding this comment.
Sorry, it's check_X_y
adam2392
left a comment
There was a problem hiding this comment.
Perhaps these will help link the different functions together?
|
@adam2392 @Charlie-XIAO this should be good now |
| `estimator=self` is automatically added to these dicts to generate | ||
| more informative error message in case of invalid input data. | ||
|
|
||
| cast_to_ndarray : bool, default=True |
There was a problem hiding this comment.
@adrinjalali I did not think too hard about the cast_to_ndarray parameter name when _valdiate_data was private. Do you see a better name for cast_to_ndarray?
There was a problem hiding this comment.
I think what this array in practice is doing is skip_check_array really. So we could call it that? With Array API and sparse arrays and all that, I don't think "casting to ndarray" is quite accurate.
There was a problem hiding this comment.
I like skip_check_array a lot more than cast_to_ndarray.
Charlie-XIAO
left a comment
There was a problem hiding this comment.
Thanks, a few more suggestions below:
Co-authored-by: Yao Xiao <108576690+Charlie-XIAO@users.noreply.github.com>
Co-authored-by: Yao Xiao <108576690+Charlie-XIAO@users.noreply.github.com>
Co-authored-by: Yao Xiao <108576690+Charlie-XIAO@users.noreply.github.com>
…into validate_data2
Alternative to and closes #29672
cc @thomasjpfan @glemaitre