Alpha

evalica.alpha(data, distance='nominal', solver='pyo3')[source]

Compute Krippendorff’s alpha.

Note

Krippendorff, K.: Content Analysis: An Introduction to Its Methodology. Sage Publications, Thousand Oaks, CA (2018).

Parameters:
  • data (DataFrame) – Ratings by observer (rows) and unit (columns).

  • distance (DistanceFunc[T_distance_contra] | Literal['interval', 'nominal', 'ordinal', 'ratio']) – Distance metric (nominal, ordinal, interval, ratio) or a custom function.

  • solver (Literal['naive', 'pyo3']) – The solver to use (naive or pyo3).

Returns:

The alpha result.

Return type:

AlphaResult

class evalica.AlphaResult(alpha, observed, expected, solver)[source]

The result of Krippendorff’s alpha.

Parameters:
alpha

The alpha value.

Type:

float

observed

The observed disagreement.

Type:

float

expected

The expected disagreement.

Type:

float

solver

The solver used.

Type:

Literal[‘naive’, ‘pyo3’]

evalica.alpha_bootstrap(data, distance='nominal', solver='pyo3', *, n_resamples=5000, confidence_level=0.95, random_state=None)[source]

Compute confidence intervals for Krippendorff’s alpha using KALPHA-style bootstrap.

Note

Krippendorff, K.: Bootstrapping Distributions for Krippendorff’s Alpha. (2006). <https://www.asc.upenn.edu/sites/default/files/2021-03/Algorithm%20for%20Bootstrapping%20a%20Distribution%20of%20Alpha.pdf>.

Note

Hayes, A.F.: Statistical Methods and Macros for SPSS, SAS, and R. <https://afhayes.com/spss-sas-and-r-macros-and-code.html>.

Parameters:
  • data (DataFrame) – Ratings by observer (rows) and unit (columns).

  • distance (DistanceFunc[T_distance_contra] | Literal['interval', 'nominal', 'ordinal', 'ratio']) – Distance metric (nominal, ordinal, interval, ratio) or a custom function.

  • solver (Literal['naive', 'pyo3']) – The solver to use (naive or pyo3).

  • n_resamples (int) – Number of bootstrap samples.

  • confidence_level (float) – The confidence level.

  • random_state (int | None) – The random seed (non-negative integer or None).

Returns:

The alpha bootstrap result.

Return type:

AlphaBootstrapResult

class evalica.AlphaBootstrapResult(alpha, observed, expected, solver, low, high, distribution, n_resamples, confidence_level)[source]

The bootstrap result of Krippendorff’s alpha.

Parameters:
alpha

The alpha value.

Type:

float

observed

The observed disagreement.

Type:

float

expected

The expected disagreement.

Type:

float

low

The lower bound of the confidence interval.

Type:

float

high

The upper bound of the confidence interval.

Type:

float

distribution

The bootstrap alpha distribution.

Type:

pandas.Series

n_resamples

The number of bootstrap samples used.

Type:

int

confidence_level

The confidence level.

Type:

float

solver

The solver used.

Type:

Literal[‘naive’, ‘pyo3’]

evalica.DistanceName

alias of Literal[‘interval’, ‘nominal’, ‘ordinal’, ‘ratio’]

class evalica.DistanceFunc(*args, **kwargs)[source]

The distance function protocol.

__call__(left, right, /)[source]

Compute the distance between the values.

Parameters:
  • left (T_distance_contra) – The left-hand side value.

  • right (T_distance_contra) – The right-hand side value.

Returns:

The non-negative distance between the values.

Return type:

float