Skip to main content

groupval

Validate language model labels within each group before comparing groups.

Language model labels can be accurate overall and still err more on one group's texts, which biases any comparison between groups. On the congressional tweets of Gilardi, Alizadeh and Kubli (2023), coders with accuracy near 0.87 overstate the Democrat minus Republican gap in political content by more than four times, because they miss more Republican political tweets. groupval reports sensitivity, specificity and error for each group, the bias in the between-group gap with an interval clustered by author, and the number of expert labels each group needs to estimate that bias to a chosen precision.

Install

pip install groupval

Use

from groupval import validate, plan_gold

r = validate(labels, gold, group, cluster=author, reference="D")
r.per_group
r.bias, r.interval
plan_gold(r.variance_by_group["D"], r.variance_by_group["R"], halfwidth=0.03)
allocate_gold(r.variance_by_group["D"], r.variance_by_group["R"], halfwidth=0.03)

labels and gold are 0/1 arrays on the expert-labeled items, group holds the two groups being compared and cluster the author or account. plan_gold gives the expert labels per group under an equal split. allocate_gold gives the split that minimizes the variance of the group gap for the same precision, with each group's share proportional to the standard deviation of the model's error in that group. python examples/simulate.py runs a small simulated case.

Reference

Crainic, J., and Yee, B. Accurate Overall, Biased Between Parties: Validating Language Model Labels Within Each Group. Extended abstract, 2026.

License

MIT

Metadata

Release files for groupval 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for groupval 0.1.1
File Size Uploaded Provenance Actions
groupval-0.1.1.tar.gz 4.1 kB With provenance Details for groupval-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for groupval 0.1.1
File Interpreter ABI Platform Actions
groupval-0.1.1-py3-none-any.whl Python 3 none any Details for groupval-0.1.1-py3-none-any.whl

Total release size: 8.1 kB

Release files / groupval-0.1.1.tar.gz

Download URL groupval-0.1.1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b723a2ce5e8f5b75f2d48784afa9f78f823b08642fbfc3c0d3113ef7f8dc941b
BLAKE2b-256 checksum
How to use checksums
51db9bc16a2e8c41cb8d4a08e757ffc368daae6f4048e14cebf8d213cb8c3346
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Release files / groupval-0.1.1-py3-none-any.whl

Download URL groupval-0.1.1-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a99ea336978c4be5798b565fbe75720e307e7f175032175d57b53a52ce3bb5a1
BLAKE2b-256 checksum
How to use checksums
8c80c1c5d1f43a0148f38195f45b49f59bf9451c9f52a7efe14f6981d8679167
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

Security for groupval 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for groupval-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page