Skip to main content

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

PyPI version Python versions License: MIT CI

๐Ÿ“– 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


๐Ÿค 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

โญ Star us on GitHub โ€ข ๐Ÿ“ง Contact

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

cvd_risk-0.1.48.tar.gz (6.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cvd_risk-0.1.48-py3-none-any.whl (5.2 MB view details)

Uploaded Python 3

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

Hashes for cvd_risk-0.1.48.tar.gz
Algorithm Hash digest
SHA256 72841c428f3fe8ccfb62a706e12bf4dfcaea403992fae93311b5397065ebec3b
MD5 b36cbdfb9078a34d816dd5c3a0ed7006
BLAKE2b-256 2cf0fdd606c39cf74cf05c0e8f3d9edde733e2af9054b7c54234dbf74b154f1c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cvd_risk-0.1.48.tar.gz:

Publisher: release.yml on m-aljasem/PyCVDRisk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for cvd_risk-0.1.48-py3-none-any.whl
Algorithm Hash digest
SHA256 d1bef848e83d2571ed160ee8f70a5153a92460ce5fb0408f3de5bc83dfa63e8f
MD5 09a8fdbef5ab610833bc6af87d267e10
BLAKE2b-256 c74cfcda5420052a6289d3e1d76f7b6fd5e9f303ee68adf842f9006e6800dcd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cvd_risk-0.1.48-py3-none-any.whl:

Publisher: release.yml on m-aljasem/PyCVDRisk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page