Skip to main content

A metric to calculate inter-annotator agreement for scenarios where several labels can be simultaneously assigned to an item

Project description

Multi-Label Agreement (ml_agreement)

Multi-Label Agreement (ml_agreement) is a Python library for measuring inter-annotator agreement in multi-label annotation tasks — scenarios where annotators can assign multiple labels (or none) to each data item. Unlike traditional agreement metrics like Cohen's Kappa or Fleiss’ Kappa, this metric is tailored for tasks where each item may receive multiple simultaneous annotations.

Key Features

  • Supports multi-label annotations (binary one-hot label vectors)
  • Handles any number of annotators and labels
  • Compatible with standard agreement normalizations: kappa, AC1, and PABAK
  • Calculates agreement:
    • For each item
    • For each label
    • Overall across the dataset
  • Provides baseline estimates like expected agreement and minimum possible agreement

Background

Inter-annotator agreement (IAA) is essential to ensure the objectivity and quality of annotated data. However, most classical metrics assume a single-label decision per annotator per item.

In contrast, many real-world NLP and social science tasks involve multi-label annotation, e.g., tagging media bias, emotions, or topics — where a sentence might validly be tagged with multiple classes.

This package defines a new agreement framework adapted for multi-label settings and implements a range of calculations to assess agreement reliability.

For a deeper discussion, see our paper ...

Installation

You can install this package via pip or clone it directly from git:

pip install ml_agreement
https://github.com/Timperator2/MultiLabelAgreement.git

Usage Example

My Project

import ml_agreement

# Each annotator assigns k labels to N items
annotator_1 = [["Science Fiction", "Action", "Comedy"], ["Drama", "Romance"], ["Horror", "Comedy"]]
annotator_2 = [["Science Fiction", "Action"], ["Romance"], ["Horror", "Comedy"]]
annotator_3 = [["Science Fiction", "Action"], ["Drama", "Romance"], ["Thriller", "Comedy"]]

all_decisions = [annotator_1, annotator_2, annotator_3]

# The data needs to be converted to binary one-hot label vectors

# The labels available to assign to each item
available_labels = ["Action", "Comedy", "Drama", "Horror", "Romance", "Science Fiction", "Thriller", "Fantasy"]

# If the data is already binary encoded, this transformation converts it back to the textual form as above
all_decisions = ml_agreement.transform_data(all_decisions, available_labels)

# Calculate the multi-label agreement using all three different methods 
# (for a discussion of each method, see the paper referenced above)
multi_label_k = ml_agreement.calculate_total_multi_label_agreement(all_decisions, "k")
multi_label_ac1 = ml_agreement.calculate_total_multi_label_agreement(all_decisions, "ac1")
multi_label_pabak = ml_agreement.calculate_total_multi_label_agreement(all_decisions, "pabak")

# Calculate the minimum possible multi-label agreement to see how low it can drop 
# with the given number of annotators and prevalence
minimum_k = ml_agreement.calculate_minimum_prevalence_agreement(all_decisions, "k")

# Calculate the prevalence of a label (in this case label_0, which is "Action")
prevalence_action = ml_agreement.calculate_label_prevalence(all_decisions, 0)

# Calculate the agreement for this label
ml_agreement_k_action = ml_agreement.calculate_label_agreement(all_decisions, 0, "k")

License

MIT License. See LICENSE file for details.

Citation

If you use this package in your research, please cite the corresponding paper.

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

ml_agreement-1.0.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

ml_agreement-1.0.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file ml_agreement-1.0.2.tar.gz.

File metadata

  • Download URL: ml_agreement-1.0.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for ml_agreement-1.0.2.tar.gz
Algorithm Hash digest
SHA256 611a87c2bf0a9a07424106e6d151d2ca322fee2bc952d33aa220b9df36977899
MD5 bf32ea54e38791477c03a52618569ad8
BLAKE2b-256 ba917e9d541dd0d9aa714a8fde3351867f82085e85b08d4e2546088b6936160d

See more details on using hashes here.

File details

Details for the file ml_agreement-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: ml_agreement-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for ml_agreement-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 668338c7b89b99193b277f214de884709d0490932a257468d01cc714ac30c090
MD5 0decfc35c72d07aa2d42a0e163c384aa
BLAKE2b-256 2483b07b47d105b72afe3e7c25b3b3aaadcb8944d3989fc391eda8f642a4fb2d

See more details on using hashes here.

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