Production-grade Python package for cardiovascular disease risk calculation
Project description
PyCVDRisk ๐ซ
World's Most Comprehensive CVD Risk Models Package
The world's most comprehensive CVD risk assessment library with global coverage
๐ Documentation โข ๐ Quick Start โข ๐ฌ Discussions
โจ What is PyCVDRisk?
PyCVDRisk is the world's most comprehensive Python package for cardiovascular disease risk prediction, implementing 46 validated models from 35+ countries. Whether you're a researcher analyzing global biobank data or a clinician integrating risk assessment into your workflow, PyCVDRisk provides accurate, validated, and easy-to-use CVD risk calculations with unmatched geographic and ethnic coverage.
๐ฏ Key Features
- 46 Production-Ready Models: World's most comprehensive CVD risk library with global coverage across 35+ countries and regions
- Global Coverage: Models from every major continent (Europe, Americas, Asia, Oceania, Middle East)
- Ethnic Diversity: 15+ ethnic groups represented (European, African American, Asian, Hispanic, Maori, Pacific Islander, etc.)
- Batch Processing: Handle thousands of patients efficiently with vectorized operations
- Type-Safe: Full type hints and validation with Pydantic
- Well-Tested: Comprehensive test suite with high code coverage
- Research-Grade: Based on peer-reviewed algorithms and clinical guidelines
๐ Global Coverage & Diversity
PyCVDRisk offers unparalleled geographic and ethnic coverage:
- Europe: 15+ models (SCORE2, PROCAM, REGICOR, Progetto CUORE, PRIME, DECODE, INTERHEART, etc.)
- Americas: 8+ models (ASCVD, Framingham, PREVENT, Reynolds, Brazilian CVD, Mexican CVD, etc.)
- Asia: 4+ models (Singapore, Malaysian CVD, QRISK2/3, SCORE2-Asia CKD)
- Oceania: 3+ models (New Zealand, PREDICT)
- Middle East: 1+ model (Gulf RACE)
- Global: 3+ models (WHO CVD, Globorisk, INTERHEART)
Special Populations Covered:
- HIV-positive patients (D:A:D Score)
- Diabetes patients (DIAL2, SCORE2-DM, DECODE)
- CKD patients (SCORE2-CKD)
- Elderly populations (SCORE2-OP, Rotterdam Study)
- Young adults (CARDIA)
- Atrial fibrillation (CHADS2, CHA2DS2-VASc)
- Anticoagulation bleeding risk (HAS-BLED)
๐ Installation
pip install cvd-risk
That's it! PyCVDRisk is now ready to use.
๐ Quick Start
Calculate Risk for One Patient
from cvd_risk import SCORE2, PatientData
# Create a patient profile
patient = PatientData(
age=55,
sex='male',
systolic_bp=140,
total_cholesterol=6.0,
hdl_cholesterol=1.2,
smoking=True,
region='moderate'
)
# Calculate 10-year CVD risk
model = SCORE2()
result = model.calculate(patient)
print(f"Risk Score: {result.risk_score:.1f}%")
print(f"Risk Category: {result.risk_category}")
Output:
Risk Score: 10.6%
Risk Category: Moderate risk
Batch Processing for Multiple Patients
import pandas as pd
from cvd_risk import SCORE2
# Load your patient data
df = pd.DataFrame({
'age': [45, 60, 55, 70],
'sex': ['female', 'male', 'male', 'female'],
'systolic_bp': [120, 150, 135, 145],
'total_cholesterol': [5.5, 7.2, 6.1, 4.8],
'hdl_cholesterol': [1.8, 1.0, 1.3, 1.5],
'smoking': [False, True, False, True],
'region': ['low', 'high', 'moderate', 'moderate']
})
# Calculate risks for all patients
model = SCORE2()
results_df = model.calculate_batch(df)
# Results are added to the original dataframe
print(results_df[['age', 'sex', 'risk_score', 'risk_category']])
๐ฅ Available Models
Primary Prevention Models
| Model | Population | Primary Use | Status |
|---|---|---|---|
| SCORE2 | European adults (40-69) | Primary prevention | โ Production Ready |
| ASCVD | US/International adults | Primary prevention | โ Production Ready |
| Framingham | US adults | Primary prevention | โ Production Ready |
| QRISK2 | UK adults | Primary prevention | โ Production Ready |
| QRISK3 | UK primary care | Primary prevention | โ Production Ready |
| SCORE | European adults | Primary prevention | โ Production Ready |
| WHO CVD | Global populations | Primary prevention | โ Production Ready |
| Globorisk | 182 countries | Primary prevention | โ Production Ready |
| INTERHEART | 52 countries | Primary prevention | โ Production Ready |
| PREVENT | US adults (40-79) | Primary prevention | โ Production Ready |
| PROCAM | German adults | Primary prevention | โ Production Ready |
| Reynolds | US adults | Primary prevention (hsCRP) | โ Production Ready |
| FINRISK | Finnish adults | Primary prevention | โ Production Ready |
| REGICOR | Spanish adults | Primary prevention | โ Production Ready |
| Progetto CUORE | Italian adults | Primary prevention | โ Production Ready |
| PRIME | France/Ireland adults | Primary prevention | โ Production Ready |
| RISC | German adults | Primary prevention | โ Production Ready |
| ARIC Update | US multi-ethnic | Primary prevention | โ Production Ready |
| Jackson Heart | US African American | Primary prevention | โ Production Ready |
| CARDIA | US young adults | Primary prevention | โ Production Ready |
| Rotterdam | Dutch elderly | Primary prevention | โ Production Ready |
| Heinz Nixdorf | German adults | Primary prevention | โ Production Ready |
| EPIC-Norfolk | UK adults | Primary prevention | โ Production Ready |
| Singapore | Singapore adults | Primary prevention | โ Production Ready |
| PREDICT | New Zealand adults | Primary prevention | โ Production Ready |
| New Zealand | New Zealand adults | Primary prevention | โ Production Ready |
| Dundee | Scottish adults | Primary prevention | โ Production Ready |
| Cambridge | UK adults | Primary prevention | โ Production Ready |
| DECODE | European adults | Primary prevention | โ Production Ready |
| NHANES | US population survey | Primary prevention | โ Production Ready |
| Malaysian CVD | Malaysian adults | Primary prevention | โ Production Ready |
| Brazilian CVD | Brazilian adults | Primary prevention | โ Production Ready |
| Mexican CVD | Mexican adults | Primary prevention | โ Production Ready |
| Gulf RACE | Gulf countries | Primary prevention | โ Production Ready |
Secondary Prevention Models
| Model | Population | Primary Use | Status |
|---|---|---|---|
| SMART2 | Established CVD patients | Recurrent CVD risk | โ Production Ready |
| SMART-REACH | Established CVD patients | Recurrent CVD risk | โ Production Ready |
Diabetes-Specific Models
| Model | Population | Primary Use | Status |
|---|---|---|---|
| DIAL2 | Type 2 diabetes patients | Lifetime CVD risk | โ Production Ready |
| SCORE2-DM | Diabetes patients | CVD risk assessment | โ Production Ready |
HIV-Specific Models
| Model | Population | Primary Use | Status |
|---|---|---|---|
| D:A:D Score | HIV-positive patients | CVD risk assessment | โ Production Ready |
CKD-Specific Models
| Model | Population | Primary Use | Status |
|---|---|---|---|
| SCORE2-CKD | CKD patients | CVD risk assessment | โ Production Ready |
| SCORE2-OP | Older persons | CVD risk assessment | โ Production Ready |
Region-Specific Models
| Model | Population | Primary Use | Status |
|---|---|---|---|
| ASSIGN | Scottish adults | Primary prevention | โ Production Ready |
| SCORE2-Asia CKD | Asian CKD patients | CVD risk assessment | โ Production Ready |
| REGICOR | Spanish adults | Primary prevention | โ Production Ready |
| Progetto CUORE | Italian adults | Primary prevention | โ Production Ready |
| PRIME | France/Ireland adults | Primary prevention | โ Production Ready |
| RISC | German adults | Primary prevention | โ Production Ready |
| Heinz Nixdorf | German adults | Primary prevention | โ Production Ready |
| EPIC-Norfolk | UK adults | Primary prevention | โ Production Ready |
| Singapore | Singapore adults | Primary prevention | โ Production Ready |
| PREDICT | New Zealand adults | Primary prevention | โ Production Ready |
| New Zealand | New Zealand adults | Primary prevention | โ Production Ready |
| Dundee | Scottish adults | Primary prevention | โ Production Ready |
| Cambridge | UK adults | Primary prevention | โ Production Ready |
| DECODE | European adults | Primary prevention | โ Production Ready |
| NHANES | US population survey | Primary prevention | โ Production Ready |
| Malaysian CVD | Malaysian adults | Primary prevention | โ Production Ready |
| Brazilian CVD | Brazilian adults | Primary prevention | โ Production Ready |
| Mexican CVD | Mexican adults | Primary prevention | โ Production Ready |
| Gulf RACE | Gulf countries | Primary prevention | โ Production Ready |
Lifetime Risk Models
| Model | Population | Primary Use | Status |
|---|---|---|---|
| LifeCVD2 | General population | Lifetime CVD risk | โ Production Ready |
Acute Coronary Syndrome Models
| Model | Population | Primary Use | Status |
|---|---|---|---|
| GRACE2 | ACS patients | 6-month mortality | โ Production Ready |
| TIMI | UA/NSTEMI patients | Short-term risk | โ Production Ready |
Emergency Department Models
| Model | Population | Primary Use | Status |
|---|---|---|---|
| EDACS | Chest pain patients | MACE risk stratification | โ Production Ready |
| HEART | Chest pain patients | MACE risk stratification | โ Production Ready |
๐ฌ Usage Examples
Clinical Integration
from cvd_risk import SCORE2, ASCVD, PROCAM, PatientData
# Compare multiple models for the same patient
patient = PatientData(
age=65, sex='male', systolic_bp=150,
total_cholesterol=6.5, hdl_cholesterol=1.1,
smoking=False
)
# European models
score2_model = SCORE2()
procam_model = PROCAM()
# US models
ascvd_model = ASCVD()
score2_result = score2_model.calculate(patient)
procam_result = procam_model.calculate(patient)
ascvd_result = ascvd_model.calculate(patient)
print(f"SCORE2 (Europe): {score2_result.risk_score:.1f}%")
print(f"PROCAM (Germany): {procam_result.risk_score:.1f}%")
print(f"ASCVD (US): {ascvd_result.risk_score:.1f}%")
Epidemiological Research
import pandas as pd
from cvd_risk import SCORE2
# Process large cohorts efficiently
biobank_data = pd.read_csv('large_cohort.csv') # 100K+ patients
# Calculate risks (takes ~1 second for large datasets)
model = SCORE2()
results_df = model.calculate_batch(biobank_data)
# Statistical analysis
high_risk = (results_df['risk_score'] > 10).sum()
total_patients = len(biobank_data)
high_risk_percentage = (high_risk / total_patients) * 100
print(f"High-risk patients: {high_risk:,} ({high_risk_percentage:.1f}%)")
Model Comparison
from cvd_risk import SCORE2, Framingham, PROCAM, Singapore, PREDICT
import pandas as pd
import numpy as np
# Compare international model predictions across a global population
np.random.seed(42)
n_patients = 100
# Generate synthetic global population data
population_df = pd.DataFrame({
'age': np.random.normal(55, 10, n_patients).clip(40, 80).astype(int),
'sex': np.random.choice(['male', 'female'], n_patients),
'systolic_bp': np.random.normal(130, 20, n_patients).clip(90, 200),
'total_cholesterol': np.random.normal(5.5, 1.2, n_patients).clip(3, 10),
'hdl_cholesterol': np.random.normal(1.3, 0.4, n_patients).clip(0.5, 2.5),
'smoking': np.random.choice([True, False], n_patients, p=[0.2, 0.8]),
'region': np.random.choice(['low', 'moderate', 'high'], n_patients),
'ethnicity': np.random.choice(['chinese', 'malay', 'indian', 'white'], n_patients)
})
# Calculate risks with international models
score2_model = SCORE2()
framingham_model = Framingham()
procam_model = PROCAM()
singapore_model = Singapore()
predict_model = PREDICT()
score2_results = score2_model.calculate_batch(population_df)
framingham_results = framingham_model.calculate_batch(population_df)
procam_results = procam_model.calculate_batch(population_df)
singapore_results = singapore_model.calculate_batch(population_df)
predict_results = predict_model.calculate_batch(population_df)
# Compare average risks across continents
avg_risks = {
'SCORE2 (Europe)': score2_results['risk_score'].mean(),
'Framingham (US)': framingham_results['risk_score'].mean(),
'PROCAM (Germany)': procam_results['risk_score'].mean(),
'Singapore (Asia)': singapore_results['risk_score'].mean(),
'PREDICT (New Zealand)': predict_results['risk_score'].mean()
}
print("Average 10-year CVD risk by international models:")
for model, risk in avg_risks.items():
print(f"{model}: {risk:.1f}%")
๐ Documentation
- Full Documentation - Complete API reference and guides
- Model Details - Clinical background for each algorithm
- Validation - How we ensure accuracy
- Contributing Guide - Add new models or improve the package
๐ค Contributing
We welcome contributions! Here's how to get involved:
Ways to Contribute
- ๐ Report bugs via GitHub Issues
- ๐ก Suggest features in Discussions
- ๐ Improve documentation by editing files
- ๐งช Add test cases or validation data
- ๐ง Implement new risk models
Development Setup
# Clone the repository
git clone https://github.com/m-aljasem/PyCVDRisk.git
cd PyCVDRisk
# Install in development mode with all dependencies
pip install -e .[dev]
# Run tests
python build_script.py test
# Run all checks (linting + tests)
python build_script.py check
๐ License
MIT License - Free for academic, clinical, and commercial use.
Just cite us in your research! ๐
๐ Acknowledgments
- European Society of Cardiology - SCORE2 algorithm
- American Heart Association - ASCVD and Framingham algorithms
- National Health Services (UK) - QRISK algorithms
- World Health Organization - Global CVD risk charts
- International Cardiology Societies - INTERHEART, PRIME, and other global studies
- National Health Ministries - Country-specific algorithms (Finland, Singapore, Thailand, Malaysia, Brazil, Mexico, etc.)
- Scientific Python Community - NumPy, Pandas, SciPy
- Open Source Contributors - Making global research software accessible
Built with โค๏ธ for global cardiovascular research and clinical practice
Project details
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 cvd_risk-0.1.48.tar.gz.
File metadata
- Download URL: cvd_risk-0.1.48.tar.gz
- Upload date:
- Size: 6.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72841c428f3fe8ccfb62a706e12bf4dfcaea403992fae93311b5397065ebec3b
|
|
| MD5 |
b36cbdfb9078a34d816dd5c3a0ed7006
|
|
| BLAKE2b-256 |
2cf0fdd606c39cf74cf05c0e8f3d9edde733e2af9054b7c54234dbf74b154f1c
|
Provenance
The following attestation bundles were made for cvd_risk-0.1.48.tar.gz:
Publisher:
release.yml on m-aljasem/PyCVDRisk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cvd_risk-0.1.48.tar.gz -
Subject digest:
72841c428f3fe8ccfb62a706e12bf4dfcaea403992fae93311b5397065ebec3b - Sigstore transparency entry: 757642995
- Sigstore integration time:
-
Permalink:
m-aljasem/PyCVDRisk@54f776ba72cda581e75bc5a81c2679397de0b376 -
Branch / Tag:
refs/tags/v0.1.48 - Owner: https://github.com/m-aljasem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@54f776ba72cda581e75bc5a81c2679397de0b376 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cvd_risk-0.1.48-py3-none-any.whl.
File metadata
- Download URL: cvd_risk-0.1.48-py3-none-any.whl
- Upload date:
- Size: 5.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1bef848e83d2571ed160ee8f70a5153a92460ce5fb0408f3de5bc83dfa63e8f
|
|
| MD5 |
09a8fdbef5ab610833bc6af87d267e10
|
|
| BLAKE2b-256 |
c74cfcda5420052a6289d3e1d76f7b6fd5e9f303ee68adf842f9006e6800dcd2
|
Provenance
The following attestation bundles were made for cvd_risk-0.1.48-py3-none-any.whl:
Publisher:
release.yml on m-aljasem/PyCVDRisk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cvd_risk-0.1.48-py3-none-any.whl -
Subject digest:
d1bef848e83d2571ed160ee8f70a5153a92460ce5fb0408f3de5bc83dfa63e8f - Sigstore transparency entry: 757643001
- Sigstore integration time:
-
Permalink:
m-aljasem/PyCVDRisk@54f776ba72cda581e75bc5a81c2679397de0b376 -
Branch / Tag:
refs/tags/v0.1.48 - Owner: https://github.com/m-aljasem
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@54f776ba72cda581e75bc5a81c2679397de0b376 -
Trigger Event:
push
-
Statement type: