Skip to content

Comparison.score.jsd

Comparison.score.jsd

jsd(
    alpha: float = 1,
    base: float = 2,
    weight_ref: float = 0.5,
    weight_cmp: float = 0.5,
    reference_score: float | Literal["mean"] | Expr = 0,
) -> Comparison

Calculates the Jensen-Shannon divergence (JSD) between the reference and comparison corpora.

Alias for jensen_shannon_divergence; see that method for more details.

Parameters:

Name Type Description Default

alpha

float

Order of the generalized entropy. \(\alpha = 1\) recovers the standard JSD. Larger values place more weight on common tokens, and smaller values place more weight on rare tokens

1

base

float

Base of the logarithms used to calculate the JSD when \(\alpha = 1\). Ignored otherwise

2

weight_ref

float

Mixture weight \(\pi_R\) for the reference corpus

0.5

weight_cmp

float

Mixture weight \(\pi_C\) for the comparison corpus

0.5

reference_score

float | Literal['mean'] | Expr

Baseline against which per-token contributions are interpreted. Defaults to 0

0

Returns:

Type Description
Comparison

A new Comparison scored by the Jensen-Shannon divergence

Source