normalize_weights¶
yohou.utils.weighting.normalize_weights(weights)
¶
Normalize weights so they sum to the number of elements.
Applies the convention weights * (n / sum(weights)) so the sum of
the returned array equals len(weights). This preserves scale when
weights are used as multiplicative factors on scores or loss values.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
weights
|
ndarray
|
Weight array. Must not sum to zero. |
required |
Returns¶
| Type | Description |
|---|---|
ndarray
|
Normalized weight array with |
Raises¶
| Type | Description |
|---|---|
ValueError
|
If |