Development build 0.1.3.9001, built from main: its README, dependencies and API documentation may describe changes that are not released. For the latest release, see qe-stats 0.1.2.
Python bindings for libqe-stats — classification metrics, sample sizes, metric derivation, bootstrap comparison and Shaffer's rho for qualitative coding
Python >=3.9 · License: GPL-3.0-only · API documentation · Source code · Homepage · Documentation
Also available for R: libqe-stats · Julia: libqe-stats · npm: @qe-libs/libqe-stats-wasm · C++ (Conan): libqe-stats
pip install --extra-index-url https://qe-libs.org/py/dev/simple/ qe-stats
uv add qe-stats --index qe-libs-dev=https://qe-libs.org/py/dev/simple/
Links in the wheel columns are the Python versions each wheel supports; pip and uv pick the right file automatically.
| Version | Published | Source | Linux x86_64 · glibc 2.27+ | macOS arm64 · macOS 26.0+ |
|---|---|---|---|---|
| 0.1.3.9001 | 2026-11-11 | .tar.gz | 3.11 3.12 3.13 | 3.11 3.12 3.13 |
| 0.1.2 | 2026-11-11 | .tar.gz | 3.11 3.12 3.13 | 3.11 3.12 3.13 |
For 0.1.3.9001.
pytest (extra: dev)Python bindings for libqe-stats, the
header-only C++ statistics for checking qualitative coding that the qestats
R package and @qe-libs/libqe-stats-wasm share: classification metrics,
hypergeometric intervals and perfect-sample sizes, metric derivation from
known metrics, bootstrap comparison of two coders, and Shaffer's rho (ported
from rhoR).
pip install qe-stats --index-url https://qe-libs.org/py/simple/
import qestats
# Metrics from a confusion matrix
m = qestats.calculate_metrics(tp=50, fp=10, fn=5, tn=100)
m["kappa"], m["precision"], m["FDR"]
# Shaffer's rho for an observed kappa of 0.88 on an 80-item test set
# from a population with base rate 0.2 (rhoR's rhoK)
qestats.rho(0.88, 0.2, 80, seed=1) # 0.1025
# How large must a perfect sample be to show kappa > 0.65?
qestats.ps_kappa(0.65, baserate=0.12) # {'n': ..., 'power': ..., 'cost': ...}
# Compare two coders' kappa
qestats.p_diff({"TP": 50, "FP": 10, "FN": 5, "TN": 100},
{"TP": 40, "FP": 20, "FN": 10, "TN": 100},
n_sample=0, metric="kappa")
Metric results are dicts keyed as in R (baserate, baserate2, precision,
recall, accuracy, FDR, FOR, kappa, and the four cells). A confusion
matrix argument is a dict with TP, FP, FN, TN or a sequence
(tp, fp, fn, tn).
| Function | R (qestats) |
|---|---|
calculate_metrics(tp, fp, fn, tn) |
qestats_calculate_metrics |
kappa_from_counts(tp, fp, fn, tn) |
— |
derive(name1, val1, name2, val2, name3, val3) |
qestats_derive |
derive_from_rates(baserate, fdr, for_rate) |
qestats_derive_from_rates |
range(name1, val1, name2, val2, target) |
qestats_range |
phyper(q, K, N_minus_K, n) |
qestats_phyper |
hyper_range(n_pos, n, N, alpha=0.05) |
qestats_hyper_range |
metrics_range(tp, fp, fn, tn, N, baserate, alpha=0.05) |
qestats_metrics_range |
ps_proportion(x0, x1=0, N=0, allowed_errors=0, alpha=0.05) |
qestats_ps_proportion |
ps_est_proportion(n, N=0, allowed_errors=0, alpha=0.05) |
qestats_ps_est_proportion |
ps_kappa(kappa0, baserate, kappa1=0, N=0, allowed_errors=0, alpha=0.05) |
qestats_ps_kappa |
ps_est_kappa(n, baserate, N=0, allowed_errors=0, alpha=0.05) |
qestats_ps_est_kappa |
bootstrap_metrics(cm, n_sample, n_set=0, n_bootstrap=1000, conf_level=0.95) |
qestats_bootstrap_metrics |
p_diff(cm1, cm2, n_sample, metric, n_set=0, n_bootstrap=1000, alpha=0.05) |
qestats_p_diff |
n_diff2(cm1, cm2, metric, N, d=0.1, alpha=0.05) |
qestats_N_Diff2 |
rho(x, baserate, test_set_length, ..., method="standard", seed=None) |
qestats_rho |
range is called as qestats.range(...); it is not exported by
from qestats import *, so the builtin is not replaced.
rho runs either of rhoR's methods: "standard" (rhoR's default, written in
R) or "fast" (its C++ path). It draws from libqe-stats' own generator
(mt19937_64), so a seed gives the same rho in Python, Julia (QEStats.jl) and
C++ on every platform; without one, each call draws a fresh seed. It cannot
reproduce a seeded rhoR call, which uses R's generator: for that, use the R
package (qestats_rho or rhoR itself).
| File | Size | SHA-256 |
|---|---|---|
| qe_stats-0.1.3.9001.tar.gz | 27.3 KB | b28d0221bcd750291297c4f5cd8e03c39eff3cd492788aa8e88e6bdf02101378 |
| qe_stats-0.1.3.9001-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | 90.4 KB | e5e0a9e69001c711bdfca865f78fc801f7a7c1c009626beed18bbdc0cc69e0f3 |
| qe_stats-0.1.3.9001-cp313-cp313-macosx_26_0_arm64.whl | 77.7 KB | 053cc0c8ee5893763f74ebcf963adc530632662ed070be7b6513cb66d11534e8 |
| qe_stats-0.1.3.9001-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | 90.4 KB | 7331452ba4b92b1024ea367a6c9c124213d2c94e7f51807ea69c79691b238300 |
| qe_stats-0.1.3.9001-cp312-cp312-macosx_26_0_arm64.whl | 77.6 KB | a50a8f6bde072870e3f63ddeaf48efaf3c7c8e85297a4aa3b0dde37473ccd91b |
| qe_stats-0.1.3.9001-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | 90.9 KB | 7c3391730b23c915d0aed8ddf58f53c193dd4a533524538f4b48a2eab7c4aa22 |
| qe_stats-0.1.3.9001-cp311-cp311-macosx_26_0_arm64.whl | 78.5 KB | 0e5c66d0cf20393b0509ccc7b62f87616197bc790a942503d32d8c4c836de1d0 |
| qe_stats-0.1.2.tar.gz | 27.3 KB | 9ace6415e05b8d30dd3c2b1aa2e59e683e9584c99793168c7302a8f15f978186 |
| qe_stats-0.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | 90.3 KB | e9d15e1a33822c06518f4443411661ad417ca953113d0b10568e5eb4f7b3f3c9 |
| qe_stats-0.1.2-cp313-cp313-macosx_26_0_arm64.whl | 77.6 KB | fcf2081cc5042e29f833bff62f94bef972eab8b77aaa1f3837946cde80b91c76 |
| qe_stats-0.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | 90.4 KB | 461665a9159b13840be0eeb820661d6f22d7a5a32dbb9fea05b1cdefd0ec4707 |
| qe_stats-0.1.2-cp312-cp312-macosx_26_0_arm64.whl | 77.6 KB | 4f8593f6bdd08e5a558ea3ef2be04c147e875a1f96ae6200372ba6f42b8c1e88 |
| qe_stats-0.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl | 90.8 KB | 7565d067587ca6f3b69b75bcfddfb8134175f2687c0eb6753c4d408344b2f9fc |
| qe_stats-0.1.2-cp311-cp311-macosx_26_0_arm64.whl | 78.4 KB | 6eac2c607ec897835484ea2e735215c17e7f396a89e325a7124509dcf09955be |