Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.


PyPI License: MIT

seminal is a Python library of published risk equations in andrology and male reproductive health, implemented with the coefficients exactly as printed in the source papers and checked against the authors' own validation data.

The first release implements the two azoospermia prediction models of Tradewell et al. (World J Mens Health 2022): a quadratic in serum FSH alone, and a logistic regression on age, FSH, LH, total testosterone and mean testis volume. Both estimate the probability that a man presenting for infertility evaluation has no sperm in the ejaculate, without a semen analysis.

Not affiliated with the original authors. This is an independent implementation of published equations, intended for research use. It is not a medical device and should not be used to make clinical decisions.

Installation

pip install seminal

Requires Python 3.8+, numpy 1.20+ and pandas 1.3+.

Usage

FSH alone

from seminal import azoospermia_fsh

azoospermia_fsh(20)
# 0.439

The published curve is U-shaped: 10.1% at undetectable FSH, a minimum of about 8.4% at FSH 3.6 IU/L, and 100% from about 30 IU/L. Output is clipped to [0, 1]; pass clip=False to reproduce the paper's unbounded quadratic.

Full logistic model

from seminal import azoospermia_lr

azoospermia_lr(age=36, fsh=5.7, lh=4.5, testosterone=429, testis_volume=15)
# 0.086

Pass explain=True to also get the linear predictor and each input's contribution to the log-odds, largest first.

A whole cohort

from seminal import add_azoospermia_risk_cols

scored = add_azoospermia_risk_cols(
    df, age_col="age", fsh_col="fsh", lh_col="lh",
    testosterone_col="testosterone", testis_volume_col="testis_volume",
)
scored[["azoo_fsh", "azoo_lr"]]

Rows missing any logistic-model input get NaN in azoo_lr; azoo_fsh needs only FSH.

The equations

FSH-only quadratic (Fig. 1): p(%) = 0.133·FSH² − 0.965·FSH + 10.1, fit to binned Miami probabilities, R² = 0.95.

Logistic regression (Table 3): p = 1 / (1 + exp(−η)) where

Term Units Coefficient
Intercept −1.9
Age years 0.02
FSH IU/L 0.13
LH IU/L 0.03
Total testosterone ng/dL −0.002
Mean testis volume cm³ (Prader orchidometer) −0.08

The paper prints the model form as 1/exp[−(b₀ + bᵢXᵢ)], which is a typesetting error (it exceeds 1); the standard logistic form is used here.

Validation against the authors' data

The study data are public under CC0 on Harvard Dataverse. make data_gen preprocess downloads them into data/ (gitignored) and the test suite then checks the implementation against the paper's external validation:

Site n AUC, logistic (paper) AUC, FSH-only (paper)
Milan 1,955 0.786 (0.79) 0.786 (0.78)
Chicago 614 0.723 (0.72) 0.708 (0.71)

Things to know about the data

  • The deposit contains all three sites as separate sheets. Miami (1,070 rows) and Chicago (643) are pre-exclusion; applying the paper's stated exclusions (prior vasectomy, Y microdeletion, solitary testis, testosterone or steroid use) gives 943 and 614 versus the paper's 946 and 596. Milan (1,955) matches exactly.
  • Chicago testis volumes are ultrasound long-axis measurements in cm (median 4.5), not orchidometer volumes in mL (median 14 to 15 at Miami and Milan). The paper does not address this; preprocessing.py labels the measurement method per site.
  • The logistic coefficients are printed to one or two significant figures. At the extremes of testosterone and age this rounding alone can move the log-odds by several tenths. A refit on the Miami data recovers full-precision values; that is planned for a later release and kept separate from the as-published model.
  • Azoospermia was confirmed on at least two semen analyses. The outcome in the Miami and Chicago sheets is sperm concentration = 0; Milan carries an explicit flag plus obstructive/non-obstructive type.

Repository layout

seminal/
├── src/seminal/      the package (equations only; no data)
├── tests/              unit tests plus optional validation against data/
├── data_gen.py         download the Dataverse file into data/raw
├── preprocessing.py    harmonize sites into data/processed
├── notebooks/          worked examples
└── Makefile            venv, install, test, data_gen, preprocess, build

Citation

If you use seminal, please cite the software (see CITATION.cff) and the original paper:

Tradewell MB, Cazzaniga W, Pagani RL, et al. Algorithms for Predicting the Probability of Azoospermia from Follicle Stimulating Hormone: Design and Multi-Institutional External Validation. World J Mens Health. 2022;40(4):600-607. doi:10.5534/wjmh.210138

License

MIT. The study data on Dataverse are CC0.

Author

Leonid Shpaner, Health Analytics Data Scientist, UCLA Health CTSI. leonshpaner.com

Metadata

Release files for seminal 0.0.0a1

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

Source distribution (sdist)

Source distribution for seminal 0.0.0a1
File Size Uploaded Provenance Actions
seminal-0.0.0a1.tar.gz 12.5 kB With provenance Details for seminal-0.0.0a1.tar.gz

Built distribution (wheel)

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

Total release size: 21.6 kB

Release files / seminal-0.0.0a1.tar.gz

Download URL seminal-0.0.0a1.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8b2d069e64c6d11c2433420e6942ca748b91794b3bd2a7c210c4441ef8ffd5b9
BLAKE2b-256 checksum
How to use checksums
43d1a21071acd8529764032d9948246785cd97490673c704c937f4548f278ef8
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 / seminal-0.0.0a1-py3-none-any.whl

Download URL seminal-0.0.0a1-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2eb5e14c624d64bd6611d13623442e58a6bdcf609c6544c597439f09d5f4843
BLAKE2b-256 checksum
How to use checksums
f845c856cd7f3b278b67c3e8296a4e31d560295f35365f08bdb883dda16e357e
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 seminal 0.0.0a1

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 seminal-0.0.0a1.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.

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