Skip to main content Switch to mobile version fewlabels 0.1.0 Design and robustness for prediction-powered inference: label budgets, non-random labelling, correlated AI annotators and clustered data.
pip install fewlabels Copy PIP instructions
Design and robustness for inference with AI predictions.
Prediction-powered inference (PPI) combines a small set of gold-standard human labels with many AI predictions and still gives valid confidence intervals. The core estimator already exists in ppi_py. fewlabels answers the questions that decide whether a PPI study works in practice:
How many labels do I need? Sample size, power and cost-optimal allocation between human labelling and model predictions, planned from a small pilot with conservative assumptions.
What if the labels were not chosen at random? Inverse probability weighted PPI for known selection probabilities (stratified or active labelling), and a sensitivity analysis with a tipping point for unknown selection.
What if I have several AI annotators? Optimal combination that accounts for correlated errors, plus a diagnostic report.
What if my data are clustered? Cluster-robust variances for patients with several images, documents from the same site, and so on.
In short: not how to compute PPI, but how to plan it and when to trust it.
pip install fewlabels Python 3.10 or newer is required. The only runtime dependency is NumPy.
Plan the label budget
A classifier with sensitivity 0.90 and specificity 0.95 will be used to estimate a prevalence of about 20 % in 50 000 records. How many records must be labelled by hand for a margin of error of 2 percentage points?
import fewlabels as fl params = fl.DesignParameters.from_proportion(prevalence=0.2, sensitivity=0.9, specificity=0.95) fl.required_labels(0.02, params, n_unlabeled=50_000) # 512 labels with PPI fl.required_labels(0.02, fl.DesignParameters(params.sd_y, r2=0.0)) # 1537 labels without With a pilot sample, plan with pessimistic parameters:
params = fl.DesignParameters.from_pilot(y_pilot, preds_pilot, conservative=True, seed=0) Estimate
result = fl.ppi_mean(y, preds_labeled, preds_unlabeled, alpha=0.05) print(result.estimate, result.ci, result.effective_labels) preds_labeled and preds_unlabeled may have several columns, one per AI annotator. Pass clusters_labeled and clusters_unlabeled for clustered data.
Labels chosen with known probabilities
pi = fl.inclusion_probabilities(uncertainty, budget=500, floor=0.01) labeled = fl.poisson_sample(pi, seed=0) # ... send the selected cases for labelling ... result = fl.ipw_ppi_mean(y_all, preds_all, labeled, pi) Check robustness
fl.selection_sensitivity(y, preds_labeled, preds_unlabeled, gamma=[1, 1.5, 2]) fl.tipping_point(y, preds_labeled, preds_unlabeled, null=0.25) print( fl.annotator_report(y, preds_labeled_matrix, names=["model_a", "model_b", "model_c"]).summary() ) Already using ppi_py?
from fewlabels.compat import ppi_mean_ci # same signature and numbers as ppi_py What is inside
fewlabels plan --prevalence 0.2 --sensitivity 0.9 --specificity 0.95 \ --half-width 0.02 --unlabeled 50000 fewlabels plan --sd-y 0.4 --r2 0.7 --budget 10000 --cost-label 20 --cost-prediction 0.05 Documentation
The user guide, the theory behind each method and the API reference are at https://yunusimanov.github.io/fewlabels.
fewlabels is the second library in a series on statistically sound use of AI systems. Its sibling anywatch provides anytime-valid post-market monitoring of deployed models.
If you use fewlabels in academic work, please cite it using the metadata in CITATION.cff or the "Cite this repository" button on GitHub, together with the original PPI and PPI++ papers listed in the documentation.
Contributions are welcome. Please read CONTRIBUTING.md and the Code of Conduct.
fewlabels is distributed under the Mozilla Public License 2.0.
Yunus Imanov, Researcher, Department of Engineering Mathematics and Artificial Intelligence, Azerbaijan Technical University, Baku, Azerbaijan. Contact: yunus.imanov.fz@student.aztu.edu.az
Released: Dec 4, 2026
Author/Maintainer: Yunus Imanov
Both files in this release have provenance metadata.
View provenance details
MPL-2.0 View SPDX License List
dev docs lint ppi test
ai-predictions cluster-sampling inverse-probability-weighting label-budget llm-annotation power-analysis ppi prediction-powered-inference sample-size sensitivity-analysis
Development Status 3 - Alpha
Intended Audience Science/Research
Operating System OS Independent
Programming Language Python :: 3
Topic Scientific/Engineering :: Artificial Intelligence
Scientific/Engineering :: Information Analysis
Scientific/Engineering :: Mathematics
Release files for fewlabels 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
Built distribution (wheel)
Total release size: 82.4 kB
Release files / fewlabels-0.1.0.tar.gz
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 Dec 4, 2026.
Release files / fewlabels-0.1.0-py3-none-any.whl
Security for fewlabels 0.1.0
Both files in this release have been uploaded with provenance metadata.
With provenance fewlabels-0.1.0.tar.gz Dec 4, 2026
With provenance fewlabels-0.1.0-py3-none-any.whl Dec 4, 2026
Attestation for fewlabels-0.1.0.tar.gz
Attestation for fewlabels-0.1.0-py3-none-any.whl
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
Dec 4, 2026 2 release files Full provenance
"PyPI", "Python Package Index", and the blocks logos are registered trademarks of the Python Software Foundation.
© 2026 Python Software Foundation
Deployed from 4d99e05











