Python port of the sensR package for Thurstonian models in sensory discrimination
Project description
sensPy
A Python port of the R package sensR for Thurstonian models in sensory discrimination analysis.
About
sensPy provides a comprehensive Python implementation of sensR, the R package for sensory discrimination methods. This project ensures:
- Numerical parity with sensR (validated against R outputs)
- Modern Python practices (type hints, dataclasses, NumPy/SciPy integration)
- Full test coverage with 500+ tests
Installation
# Install with pip
pip install senspy
# Or install from source
git clone https://github.com/aigorahub/sensPy.git
cd sensPy
pip install -e .
Features
Discrimination Protocols
All standard protocols with single and double variants:
| Protocol | Single | Double |
|---|---|---|
| Triangle | ✅ | ✅ |
| Duo-Trio | ✅ | ✅ |
| 2-AFC | ✅ | ✅ |
| 3-AFC | ✅ | ✅ |
| Tetrad | ✅ | ✅ |
| Hexad | ✅ | - |
| 2-out-of-5 | ✅ | - |
Statistical Models
discrim()- D-prime estimation with confidence intervals and p-valuesbetabin()- Beta-binomial model for overdispersed datatwoac()- 2-Alternative Certainty modelsamediff()- Same-different modeldod()- Degree-of-difference modelanota()- A-not-A signal detection model
Power & Sample Size
discrim_power(),dprime_power()- Power analysisdiscrim_sample_size(),dprime_sample_size()- Sample size calculationsamediff_power()- Same-different power (simulation-based)twoac_power()- 2-AC exact powerdod_power()- DOD power analysis
Inference & Comparison
dprime_test()- Test d-prime hypothesesdprime_compare()- Compare d-primes across groupsposthoc()- Post-hoc pairwise comparisons
ROC & Signal Detection
roc()- ROC curve computationauc()- Area under the ROC curvesdt()- Signal detection theory transforms
Simulation
discrim_sim()- Simulate discrimination experimentssamediff_sim()- Simulate same-different datadod_sim()- Simulate DOD data
Visualization
plot_psychometric()- Psychometric functionsplot_roc()- ROC curvesplot_power_curve()- Power curvesplot_profile_likelihood()- Profile likelihood
Quick Start
from senspy import discrim, discrim_power
# Analyze a Triangle test result (80 correct out of 100)
result = discrim(correct=80, total=100, method="triangle")
print(f"d-prime: {result.d_prime:.3f}")
print(f"95% CI: [{result.ci_lower:.3f}, {result.ci_upper:.3f}]")
print(f"p-value: {result.p_value:.4g}")
# Calculate power for a future test
power = discrim_power(d_prime=1.5, sample_size=100, method="triangle")
print(f"Power: {power:.1%}")
from senspy import samediff, dprime_compare
# Same-different analysis
sd = samediff(nsamesame=45, ndiffsame=5, nsamediff=20, ndiffdiff=30)
print(f"delta: {sd.delta:.3f}, tau: {sd.tau:.3f}")
# Compare d-primes across products
result = dprime_compare(
correct=[80, 65, 90],
total=[100, 100, 100],
method="triangle"
)
print(f"Chi-square: {result.statistic:.2f}, p={result.p_value:.4f}")
Disclaimer
Beta Release — sensPy is currently in beta. While we strive for numerical accuracy and validate results against the original sensR package, this software is provided "as is", without warranty of any kind. Aigora assumes no liability for any decisions, outcomes, or consequences arising from the use of this software. Users are responsible for independently verifying results before relying on them in production, regulatory, or research contexts.
License
This project is licensed under the GNU General Public License version 2.0 or later. See LICENSE for details.
Citation
If you use sensPy in your research, please cite:
@software{senspy,
title = {sensPy: Python port of sensR for Thurstonian models},
author = {Aigora},
year = {2025},
url = {https://github.com/aigorahub/sensPy}
}
Acknowledgments
This package is a port of sensR by Per Bruun Brockhoff and Rune Haubo Bojesen Christensen.
Project details
Release history Release notifications | RSS feed
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 senspy-0.2.0.tar.gz.
File metadata
- Download URL: senspy-0.2.0.tar.gz
- Upload date:
- Size: 73.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce6a794215184c033bca258805dc89b3d1af5bace46384cd4627454ef24c0b01
|
|
| MD5 |
06eabb7ca64fe2f1eb98ca1d8d642f1c
|
|
| BLAKE2b-256 |
595b716eb35c9f1449fc8af68ea569b300a199b4bde9e8f6f89000b3ceb7b047
|
Provenance
The following attestation bundles were made for senspy-0.2.0.tar.gz:
Publisher:
publish.yml on aigorahub/sensPy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
senspy-0.2.0.tar.gz -
Subject digest:
ce6a794215184c033bca258805dc89b3d1af5bace46384cd4627454ef24c0b01 - Sigstore transparency entry: 1017432032
- Sigstore integration time:
-
Permalink:
aigorahub/sensPy@4fb806844741ebe9cf22d446bd49a855e8cdc206 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/aigorahub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4fb806844741ebe9cf22d446bd49a855e8cdc206 -
Trigger Event:
release
-
Statement type:
File details
Details for the file senspy-0.2.0-py3-none-any.whl.
File metadata
- Download URL: senspy-0.2.0-py3-none-any.whl
- Upload date:
- Size: 84.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5a50a095b62640ed17326e5a9adab0338e5c7e8e489390f0aed8b05a8bfd272
|
|
| MD5 |
b63c195dd643b5f289b19b8cd682922f
|
|
| BLAKE2b-256 |
41ee7e68dc4f1ccc973efdc8e7883421264d9e0513a3857705bd52c4f89724bb
|
Provenance
The following attestation bundles were made for senspy-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on aigorahub/sensPy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
senspy-0.2.0-py3-none-any.whl -
Subject digest:
c5a50a095b62640ed17326e5a9adab0338e5c7e8e489390f0aed8b05a8bfd272 - Sigstore transparency entry: 1017432118
- Sigstore integration time:
-
Permalink:
aigorahub/sensPy@4fb806844741ebe9cf22d446bd49a855e8cdc206 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/aigorahub
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4fb806844741ebe9cf22d446bd49a855e8cdc206 -
Trigger Event:
release
-
Statement type: