A Python implementation of the Dietary Inflammatory Index (DII) calculator for nutritional epidemiology research
Project description
DII Calculator
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)
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
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 dii_calculator-1.0.11.tar.gz.
File metadata
- Download URL: dii_calculator-1.0.11.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fad49fef1d103b4c215471c9835c6f6b37ba2c847b291e684fb95ca55cb6bc1c
|
|
| MD5 |
6cb94bb65d18398c4ad4074fef332da8
|
|
| BLAKE2b-256 |
ae96cbb66fa1d7bca96a69fe24fb1277c68a5adb2f22bd53d2b1cd10b9641403
|
Provenance
The following attestation bundles were made for dii_calculator-1.0.11.tar.gz:
Publisher:
publish.yml on strathlab-data/DII
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dii_calculator-1.0.11.tar.gz -
Subject digest:
fad49fef1d103b4c215471c9835c6f6b37ba2c847b291e684fb95ca55cb6bc1c - Sigstore transparency entry: 769656938
- Sigstore integration time:
-
Permalink:
strathlab-data/DII@c474270d77eed090fc943006f0c49e1c42f40d9a -
Branch / Tag:
refs/tags/1.0.11 - Owner: https://github.com/strathlab-data
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c474270d77eed090fc943006f0c49e1c42f40d9a -
Trigger Event:
push
-
Statement type:
File details
Details for the file dii_calculator-1.0.11-py3-none-any.whl.
File metadata
- Download URL: dii_calculator-1.0.11-py3-none-any.whl
- Upload date:
- Size: 19.8 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 |
42ad4e239b2c5381b2250fbf1b5f0916e1ce2d356d729ae4870d8203937d9b0d
|
|
| MD5 |
b3dc6776d3b8662b4f4360d0a4c38376
|
|
| BLAKE2b-256 |
1abc34fefff7aec68ccb709f05a8810dd81dfb9ca1ceda251e5e02671948fbb0
|
Provenance
The following attestation bundles were made for dii_calculator-1.0.11-py3-none-any.whl:
Publisher:
publish.yml on strathlab-data/DII
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dii_calculator-1.0.11-py3-none-any.whl -
Subject digest:
42ad4e239b2c5381b2250fbf1b5f0916e1ce2d356d729ae4870d8203937d9b0d - Sigstore transparency entry: 769656958
- Sigstore integration time:
-
Permalink:
strathlab-data/DII@c474270d77eed090fc943006f0c49e1c42f40d9a -
Branch / Tag:
refs/tags/1.0.11 - Owner: https://github.com/strathlab-data
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c474270d77eed090fc943006f0c49e1c42f40d9a -
Trigger Event:
push
-
Statement type: