Comparison.normalize
Comparison.normalize ¶
Returns a new Comparison whose token contributions are normalized onto a common scale.
Example
Each scoring measure produces a per-token contribution \(\delta_\tau\). Normalization divides every contribution by a single constant, either the total difference between the corpora \(\sum_\tau |\delta_\tau|\) or their net difference \(|\sum_\tau \delta_\tau|\), so that scores become interpretable and comparable across measures.
For what each strategy means and how to read a normalized score, see Normalization.
Warning
By default, using this method forces the comparison to be evaluated eagerly rather than
lazily, because validating it requires computing the scores over the full vocabulary.
The eager validation can be skipped using the check_nonzero parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
NormalizeBy
|
The normalization strategy. |
required |
|
bool
|
Whether to check whether the normalization constant is zero and raise an error. If
|
True
|
Returns:
| Type | Description |
|---|---|
Comparison
|
A new |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
ValueError
|
If the comparison is already normalized by a different strategy. |
ValueError
|
If |
ValueError
|
If |