Statys
Statys provides descriptive measures, pairwise non-parametric tests, Friedman and Iman-Davenport statistics, Nemenyi critical differences, and comparison plots.
Installation
Statys requires Python 3.11 or newer. Add it to a project managed by uv with:
uv add statys
For a consumer installation in an existing Python environment, pip is also supported:
pip install statys
Repeated comparisons
import numpy as np
from statys import friedman, nemenyi, plot_critical_difference
scores = np.array(
[
[0.82, 0.79, 0.75],
[0.80, 0.77, 0.78],
[0.84, 0.81, 0.76],
[0.79, 0.75, 0.74],
]
)
print(friedman(scores))
ranks, critical_difference = nemenyi(scores)
plot_critical_difference(
ranks,
critical_difference,
labels=["Model A", "Model B", "Model C"],
output="critical-difference.pdf",
)
Rows are experimental blocks and columns are the treatments being compared.
Smaller values receive lower ranks, with average ranks for ties. For metrics
where larger is better (such as accuracy), use nemenyi(-scores) to give
better treatments lower ranks.
friedman returns ((chi_square, df), (F, (df1, df2))), with tie correction
from SciPy and an Iman-Davenport F statistic. Perfect agreement between
non-constant block rankings gives F = inf. NaN inputs or blocks that all
tie every treatment give undefined (nan) statistics, not evidence for
the null hypothesis.
Measures and pairwise tests
from statys import measures, pairwise, significance
control = [0.82, 0.80, 0.84, 0.79]
model_a = [0.79, 0.77, 0.81, 0.75]
model_b = [0.75, 0.78, 0.76, 0.74]
print(measures.mean(control, model_a, model_b))
results = pairwise.signed_rank(control, model_a, model_b)
significance.plot_p_value(
results,
labels=["Control", "Model A", "Model B"],
output="p-values.pdf",
)
The measures module also provides kurtosis, max, median, min, rank,
skewness, std, and var. The pairwise module provides u_test,
signed_rank, and rank_sum.
Pairwise results map arg{i}-arg{j} (i < j) to (reject, p_value), in input
order. reject is 1 when p_value < alpha and 0 otherwise; p-values are
not adjusted for multiple comparisons. Additional keyword arguments are
forwarded to SciPy. The signed-rank test requires aligned, paired observations;
the other two tests compare independent samples. Use u_test rather than
rank_sum when tie correction is needed.
A test producing a non-finite p-value raises ValueError identifying the
affected pair rather than reporting a false no-rejection decision. Missing
data handling can be selected explicitly, for example with nan_policy="omit".
Significance plots mirror each stored comparison into both matrix halves.
For one-sided tests, that result retains the original input order; the
mirrored cell is not a test in the opposite direction. Missing comparisons
remain blank. P-value colors use 1 - p on a fixed zero-to-one scale, so
colors have the same meaning across plots; annotations show the original
p-values.
Development
uv sync
uv run pytest
uv run pre-commit run --all-files
uv build
Documentation is available at statys.readthedocs.io.
Releasing
Use uv version --bump patch (or the appropriate version increment), update
statys.__version__ to match, and open a pull request for review.
After the pull request is merged into main and the full CI matrix succeeds,
the release job publishes the untagged version to PyPI and creates a GitHub
release and tag at that commit. Already-tagged versions are not republished.
Publication uses the repository's PYPI_API_TOKEN secret and does not depend
on a local CLI session.
Publishing a GitHub release manually remains supported; its tag must match
the package version, prefixed with v. First attempts fail on duplicate PyPI
files. An explicit rerun of the same workflow can resume a partial upload,
skipping existing files rather than replacing them.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file statys-2.0.2.tar.gz.
File metadata
- Download URL: statys-2.0.2.tar.gz
- Upload date:
- Size: 16.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1aa0166e811799d9834bfd8c880b138880d51283d39b0a2c7ae57d976fd821f3
|
|
| MD5 |
f7f854bedde31ba6f4978ed43d0e675c
|
|
| BLAKE2b-256 |
2b70b68e109b3cd3c3768e75741f008bdee8eca6987ea3a2a6b900da54ee178a
|
File details
Details for the file statys-2.0.2-py3-none-any.whl.
File metadata
- Download URL: statys-2.0.2-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98e9a72a7d34b464ee29712e9be8e97a51dfdbc13b823ff92f4b4c9e928fe2d6
|
|
| MD5 |
d2119634527be8129fea29367e176305
|
|
| BLAKE2b-256 |
4fec41185cb54ea5276f0fd38c9b1091a4d72ab6eb68a983d56d0c6418d123e8
|