Skip to main content

A Python implementation of the Dietary Inflammatory Index (DII) calculator for nutritional epidemiology research

Project description

DII Calculator

PyPI version Python 3.10+ License: MIT

A Python implementation of the Dietary Inflammatory Index (DII) for nutritional epidemiology research.

The Dietary Inflammatory Index is a literature-derived, population-based index that assesses the inflammatory potential of an individual's diet. This package provides a validated implementation for calculating DII scores from nutrient intake data.


Installation

pip install dii-calculator

Quick Start

import pandas as pd
from dii import calculate_dii

# Load your nutrient intake data
nutrients = pd.read_csv("your_data.csv")

# Calculate DII scores
results = calculate_dii(nutrients)
print(results)

Output:

   DII_score
0      -1.23
1       0.45
2       2.87

Interpretation

DII Score Dietary Pattern
Negative (< 0) Anti-inflammatory diet
Near zero Neutral
Positive (> 0) Pro-inflammatory diet

Scores typically range from -8 (maximally anti-inflammatory) to +8 (maximally pro-inflammatory).


Features

Detailed Output

Get per-nutrient contributions to understand what's driving the score:

detailed = calculate_dii(nutrients, detailed=True)
print(detailed[["Fiber_contribution", "Saturated fat_contribution", "DII_score"]])

Visualization

from dii import plot_dii_distribution, plot_nutrient_contributions

plot_dii_distribution(results)
plot_nutrient_contributions(detailed)

DII Score Distribution

Command Line

dii input.csv -o results.csv
dii input.csv --detailed
dii --nutrients  # List supported nutrients

Input Format

Your DataFrame should have columns matching DII nutrient names. The package supports all 45 DII parameters:

participant_id,Fiber,Alcohol,Vitamin C,Saturated fat,Energy
1,18.8,13.98,118.2,28.6,2056
2,25.0,0.0,150.0,22.0,1800

Run dii --nutrients to see all supported nutrients and their units.

Note: Nutrients not in your data are automatically excluded from the calculation.


Validation

Validated against 13,580 NHANES participants with perfect match to the dietaryindex R package.


Citation

If you use this package in your research, please cite:

@software{clark2025dii,
  author = {Clark, Ted and Strath, Larissa},
  title = {dii-calculator: Dietary Inflammatory Index Calculator for Python},
  year = {2025},
  url = {https://github.com/strathlab-data/DII}
}

Also cite the original DII methodology:

Shivappa N, Steck SE, Hurley TG, Hussey JR, Hébert JR. Designing and developing a literature-derived, population-based dietary inflammatory index. Public Health Nutr. 2014;17(8):1689-1696.


License

MIT License — see LICENSE for details.


Authors

  • Ted Clark — University of Florida
  • Larissa Strath, PhD — University of Florida

Department of Health Outcomes and Biomedical Informatics

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

dii_calculator-1.0.12.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

dii_calculator-1.0.12-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file dii_calculator-1.0.12.tar.gz.

File metadata

  • Download URL: dii_calculator-1.0.12.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dii_calculator-1.0.12.tar.gz
Algorithm Hash digest
SHA256 05b72302382d690f1f2cbe56ab473dcb7a4860b2c0598d929cac4cae6c9ac483
MD5 ece120335d9fa5e1fcf8fb03d7fe1a9a
BLAKE2b-256 3c7a81ee4cf5202c8bd76d3dd7922f6cdd24ae4ff7cd4b4c151c16e18f232b0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for dii_calculator-1.0.12.tar.gz:

Publisher: publish.yml on strathlab-data/DII

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

File details

Details for the file dii_calculator-1.0.12-py3-none-any.whl.

File metadata

File hashes

Hashes for dii_calculator-1.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 0f0128a926d5a8e34d74137b8f15b2d751e932c2047dcf7e37d1a061672ba051
MD5 23f5a4921d8f79633d8af0c44d0906ef
BLAKE2b-256 e93409ce7d2311f871cad25fa2c41ef7b55e4a7de7d03a253191e8bdc53ecae7

See more details on using hashes here.

Provenance

The following attestation bundles were made for dii_calculator-1.0.12-py3-none-any.whl:

Publisher: publish.yml on strathlab-data/DII

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