Health Factor Scoring
How we quantify positive health behaviors
Overview
The health factor scoring system quantifies positive health behaviors and social determinants that contribute to overall wellness. Unlike risk factors that reduce your health score, health factors increase it.
This document describes the technical implementation in our health_factor.py module.
Technical Architecture
Data Ingestion
Survey responses are provided as a dictionary, with each logical question ID mapped to a numeric key:
survey_data = {
'income': 3, # Income bracket
'education': 4, # Education level
'exercise_freq': 5, # Exercise frequency
# ... more responses
}The scorer uses database-driven mappings for question IDs and accepted responses, ensuring consistency and easy updates.
Scoring Components
Each aspect of health is scored independently through modular methods:
1. Income (_income)
Higher income is associated with better health outcomes due to: - Access to quality healthcare - Healthier food options - Safer living conditions - Lower chronic stress
Implementation: - Extracts income bracket response - Maps to normalized score (0-1) - Higher brackets yield higher scores
2. Education (_education)
Education level correlates with health literacy, preventive care, and lifestyle choices.
Scoring: - Higher education levels yield higher scores - Based on evidence that education is a strong predictor of health outcomes
3. Exercise (_exercise)
Physical activity is one of the most impactful health behaviors.
Calculation:
weekly_hours = frequency × duration
score = min(weekly_hours / optimal_hours, 1.0)Helper methods: - _compute_weekly_exercise_hours: Combines frequency and duration - _parse_exercise_amount: Normalizes input formats
Optimal range: 150-300 minutes/week of moderate activity (WHO guidelines)
4. Sleep (_sleep)
Sleep duration follows a U-shaped curve—both too little and too much can indicate health issues.
Scoring logic:
if 7 <= hours <= 9:
score = 1.0 # Optimal
elif 6 <= hours < 7 or 9 < hours <= 10:
score = 0.8 # Acceptable
else:
score = 0.5 # SuboptimalHelper: _parse_sleep_amount normalizes various input formats
5. Nutrition (_nutrition)
Dietary factors assessed: - Fruit and vegetable intake - Processed food consumption - Hydration - Meal regularity
Implementation: - Each factor contributes to total nutrition score - Evidence-based thresholds (e.g., 5 servings fruits/veg per day)
6. Immune System (_immunesystem)
Indicators of immune health: - Vaccination status - Frequency of illness - Recovery time - Preventive care
7. Mental Health (_mental_health)
Psychological wellbeing factors: - Stress management - Social support - Mental health care access - Mood stability
Note: This complements but doesn’t replace clinical mental health assessment.
Aggregation
The total health factor score combines all components:
\[ \text{Health Factor Score} = \sum_{i=1}^{n} w_i \cdot s_i \]
Where: - \(w_i\) = weight for component \(i\) - \(s_i\) = normalized score (0-1) for component \(i\) - \(n\) = number of components
Current weights are equal (1.0) but can be adjusted based on emerging evidence.
Validation
Our health factor scoring has been validated against:
- Clinical outcomes: Correlation with reduced hospital admissions
- Self-reported health: Agreement with validated health surveys (SF-36)
- Longitudinal data: Improvement in scores correlates with health improvements
See our Scoring Audit for detailed validation results.
Future Enhancements
Planned improvements: - Personalized weights based on age, sex, and conditions - Dynamic scoring that adapts to individual baselines - Temporal factors accounting for recent vs. long-term behaviors - Social determinants expanded to include neighborhood, environment
Open Source
Full implementation available at: github.com/preacterik/preact-health-scoring
Review the code, suggest improvements, or contribute enhancements.
References
- World Health Organization. Physical Activity Guidelines (2020)
- National Sleep Foundation. Sleep Duration Recommendations (2015)
- US Dietary Guidelines for Americans (2020-2025)
- Social Determinants of Health Research (CDC)
Last updated: February 17, 2026