-
-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Open
Description
Noticed while working on: #31701
_check_sample_weight
gives the following error message:
scikit-learn/sklearn/utils/validation.py
Lines 2207 to 2208 in 9489ee6
if sample_weight.ndim != 1: | |
raise ValueError("Sample weights must be 1D array or scalar") |
I don't think sample weights can ever be a scalar. Indeed later we check:
scikit-learn/sklearn/utils/validation.py
Lines 2210 to 2213 in 9489ee6
if sample_weight.shape != (n_samples,): | |
raise ValueError( | |
"sample_weight.shape == {}, expected {}!".format( | |
sample_weight.shape, (n_samples,) |
So it actually can't be a scalar.
Just to be sure I searched for "weight :" and "weights :" in our docstrings and found that we always ask for and ndarray for sample_weights
.
For clustering weights
is a string or callable. In the times where weights can be a scalar (e.g., in VotingRegressor
or 'class_weights', we never use _check_sample_weight
.)
Metadata
Metadata
Assignees
Labels
No labels