Skip to main content

A robust implementation of Krippendorff's Alpha for inter-annotator agreement

Project description

Krippendorff's Alpha

A Python implementation of Krippendorff's Alpha, a statistical measure of inter-rater reliability designed for various data types (Nominal, Ordinal, Interval, and Ratio).

✔️ Support for multiple data types (Nominal, Ordinal, etc.)

✔️ Custom weights for annotator impact on annotation assignments

✔️ Performance optimizations

✔️ Fine-grained output for categorical values

This project is inspired by the following open-source implementations of Krippendorff's Alpha listed below:

Setup

This project uses UV for dependency management.

Steps:

Install UV using UV Install Guide

After installing UV, you can then follow the instruction below.

Run:

uv run

Set Python interpreter in IDE:

.venv/bin/python3.13

Note: This project requires Python 3.13 or higher.

Done. You're set up!


Project Structure

Project Structure Overview

The project is structured to ensure modularity, scalability, and ease of use. Below is a breakdown of the key components:

  • src/krippendorff_alpha/
    Contains the core implementation of Krippendorff's Alpha, including modules for preprocessing, reliability computation, and metric calculation.

  • datasets/
    Contains example datasets in TSV format to demonstrate the usage of Krippendorff's Alpha for different data types (nominal, ordinal, interval, ratio).

  • notebooks/
    Contains usability examples for the code.


Installation

pip install krippendorff-aleph-alpha

Or using UV:

uv add krippendorff-aleph-alpha

Usage

import pandas as pd
from krippendorff_alpha import compute_alpha
from krippendorff_alpha.schema import ColumnMapping

# Load your data
df = pd.read_csv("your_data.tsv", sep="\t")

# Define column mapping
column_mapping = ColumnMapping(
    text_col="text",
    annotator_cols=["annotator1", "annotator2", "annotator3"]
)

# Compute Krippendorff's alpha
results = compute_alpha(
    df=df,
    data_type="nominal",
    column_mapping=column_mapping
)

print(f"Alpha: {results['alpha']}")

Limitations

  1. Krippendorff's alpha is more meaningful for larger data samples, however low agreement can still be a sign of labeling issue.
  2. The code requires at least three annotator columns to compute inter-annotator agreement.
  3. The function computes Krippendorff's alpha but does not provide statistical significance (e.g., confidence intervals).

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! See the Contributing.md

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

krippendorff_aleph_alpha-0.1.17.tar.gz (12.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

krippendorff_aleph_alpha-0.1.17-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file krippendorff_aleph_alpha-0.1.17.tar.gz.

File metadata

File hashes

Hashes for krippendorff_aleph_alpha-0.1.17.tar.gz
Algorithm Hash digest
SHA256 ed5c5b7af7d49dc87e9a1ad2f9da47bf1274efa6e43eb0f0e8f06c0ddbff25cc
MD5 e0b027653eed303d42001fb187de1936
BLAKE2b-256 45216b39fbe1de3eb5f5ceabf8c967d5dc2b3a1d389b8a67041a4d0d0561f10c

See more details on using hashes here.

Provenance

The following attestation bundles were made for krippendorff_aleph_alpha-0.1.17.tar.gz:

Publisher: publish.yml on Aleph-Alpha/krippendorff-aleph-alpha

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file krippendorff_aleph_alpha-0.1.17-py3-none-any.whl.

File metadata

File hashes

Hashes for krippendorff_aleph_alpha-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 68590f0cba09df10c27e0df481e0f3acd872336064be2f89a738fa39d1f1d4d6
MD5 61d1c3171e962df22afca9714a084637
BLAKE2b-256 5dffc2d27562a731323139da4d3c837daa358219042e7df677da133509587434

See more details on using hashes here.

Provenance

The following attestation bundles were made for krippendorff_aleph_alpha-0.1.17-py3-none-any.whl:

Publisher: publish.yml on Aleph-Alpha/krippendorff-aleph-alpha

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page