Skip to content

Repository files navigation

FitAI — Physiologically Reactive AI Fitness System

Reviewer guide

  • Current research code (research-current) — the advanced FitAI research MVP with latent-state and BAI assessment, architecture comparison, PostgreSQL persistence, evaluation workflow, and 54 passing tests.
  • Stable live demo (main) — the verified baseline currently deployed on Render:
    https://fitai-research.onrender.com/
  • Deployment status — the advanced research branch is kept separate from the public demo until its Docker/PostgreSQL deployment and prospective athlete validation are completed.

The live demo demonstrates the stable FitAI baseline.
The default research-current branch contains the latest research architecture referenced in the project presentation.

Final athlete-assessment MVP

FitAI is an athlete-specific physiological and latent bioenergetic research system. BAI is an experimental adaptation proxy, not a mitochondrial measurement, diagnosis, or clinically validated score.

Flow: athlete measurements -> canonical 23 features -> trained 23x8 model plus six-encoder research VAE -> BAI/states -> personal/reference comparison -> HJB-inspired safety control -> persisted recommendation.

The trained NumPy artifact is present; a saved hierarchical VAE checkpoint is not. Results disclose this limitation and reduce confidence.

PostgreSQL

Copy-Item .env.example .env
docker compose up -d db
$env:DATABASE_URL='postgresql://fitai:replace-with-a-strong-password@localhost:5432/fitai'
python manage.py migrate

Standard POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_HOST, and POSTGRES_PORT variables are also supported. SQLite is the debug/test fallback.

Demo, arbitrary input, and tests

python -m ml.demo_athlete_assessment --output demo_assessment_output.json
python -m ml.demo_athlete_assessment --input athlete.json --output result.json
python -m compileall -q fitai fitness ml tests
python manage.py makemigrations --check --dry-run
python manage.py check
python -m pytest -q

Use --no-persist for a read-only assessment. See docs/final_mvp_implementation.md, docs/datasets.md, docs/bai_interpretation.md, and docs/presentation_demo.md.

Live Demo

https://fitai-research.onrender.com/

Press "Get Started" to explore the onboarding flow and interactive physiological AI dashboard. FitAI is an experimental AI-driven physiological fitness platform built with Django, NumPy, OpenCV, and custom mathematical modeling.

image

The project combines:

  • 23 physiological input parameters
  • OpenCV-based body photo analysis
  • custom NumPy neural networks
  • stochastic physiological simulation
  • explainability analysis
  • dynamic training optimization
  • physiological risk modeling
  • longitudinal monitoring systems
  • temporal prediction tracking

Unlike traditional static fitness calculators, FitAI is designed as a physiologically reactive neural system rather than a fixed rule-based predictor.

Physiologically Reactive Neural System

The monitoring system tracks longitudinal neural predictions, physiological stability, and adaptive output dynamics over time.

Physiological Responce Analysis

The system dynamically adapts predictions based on:

  • HRV
  • sleep quality
  • emotional stress
  • inflammation markers
  • alcohol exposure
  • cardiovascular state
  • hormonal signals
  • recovery dynamics

Core Features

Physiological Prediction Engine

FitAI predicts 8 physiological and fitness-related outputs:

  • Calories Burned
  • 1 km Run Time
  • Cooper Test Distance
  • Max Pull-Ups
  • Burpees Capacity
  • 10 km Run Time
  • Waist Circumference Change
  • Testosterone Projection

The prediction engine uses: Custom NumPy Neural Network

  • custom NumPy neural networks
  • hyperbolic tangent activations (tanh)
  • softplus physiological output constraints
  • momentum optimization
  • gradient clipping
  • early stopping
  • normalization scaling
  • physics-based target generation

The neural network is implemented entirely without high-level deep learning frameworks.


Physiological Input System

The system combines:

  • 23 physiological parameters
Physiological Signal Flow
  • OpenCV body proportion analysis from uploaded user photos

Physiological inputs include:

  • HRV
  • Sleep
  • Emotional Stress
  • CRP
  • Testosterone
  • Cortisol
  • Resting Heart Rate
  • Blood Pressure
  • Waist Circumference
  • Alcohol Exposure
  • Recovery Metrics
  • Performance Metrics

The OpenCV analysis module extracts: OpenCV Body Analysis

  • shoulder width
  • waist width
  • hip width
  • body ratios
  • physique classification
  • training recommendations

Physiologically Reactive Neural Architecture

A major design goal of FitAI was to avoid creating a random black-box predictor.

The neural system was explicitly designed to demonstrate:

  • structured physiological behavior
  • parameter sensitivity
  • explainability
  • stable physiological responses

The model behavior is validated through:

Relative Perturbation Analysis (+30%)

Each physiological feature is independently perturbed by +30% to measure how predictions react.

Gradient-Based Sensitivity Analysis (∂y/∂x)

image

Local physiological sensitivity is estimated numerically through gradient-based feature analysis.

This means the model does not simply output arbitrary values.

The network dynamically and consistently reacts to physiological changes.

Predictions structurally respond to:

  • HRV
  • sleep quality
  • emotional stress
  • CRP inflammation markers
  • alcohol exposure
  • testosterone
  • cardiovascular parameters

Observed physiological behaviors include:

  • increased sleep improving recovery-related outputs
  • emotional stress worsening endurance predictions
  • elevated CRP reducing aerobic performance
  • HRV strongly affecting endurance and recovery metrics
  • alcohol negatively affecting recovery and hormonal projections

FitAI therefore behaves as a:

Structured Physiological Response Model

rather than a purely statistical estimator.


Explainability System

FitAI includes a built-in explainability pipeline.

The project generates:

  • feature_importance.json
  • per-output sensitivity analysis
  • relative perturbation analysis
  • gradient sensitivity analysis

This allows visualization of:

  • which physiological parameters affect each output
  • how strongly the neural system reacts
  • whether predictions remain physiologically consistent

Examples:

  • HRV strongly affects Cooper performance
  • Sleep strongly affects Testosterone and recovery
  • Emotional stress strongly affects endurance metrics
  • CRP affects inflammation-sensitive outputs

Model Evaluation & Monitoring System

FitAI includes an experimental physiological monitoring and evaluation framework designed to track neural network behavior over time.

The platform does not simply display predictions.

Instead, it continuously monitors:

  • prediction consistency
  • physiological trend dynamics
  • temporal stability
  • recovery behavior
  • cardiovascular response
  • hormonal tendencies
  • prediction drift across sessions

The evaluation architecture combines two independent systems.


Stability Metrics

The Stability system measures real neural network behavior across historical onboarding sessions.

Tracked statistics include:

  • Stability Mean
  • Stability Standard Deviation
  • Stability Drift

This layer evaluates:

  • prediction consistency
  • longitudinal behavior
  • temporal variance
  • real historical neural response dynamics

Stability metrics are calculated directly from historical prediction records generated by the neural network itself.


Synthetic Metrics

s2

The Synthetic system is a separate rule-based physiological simulation layer.

It generates lightweight physiological reference estimates using:

  • HRV
  • sleep
  • emotional stress
  • CRP
  • weight
  • cardiovascular signals

Synthetic metrics include:

  • Synthetic Mean
  • Synthetic Standard Deviation
  • Synthetic Drift

This system acts as:

  • a physiological comparison baseline
  • a simulation-oriented monitoring layer
  • an auxiliary consistency reference

The synthetic layer is implemented independently from the neural network through the synthetic_ground_truth() simulation pipeline.


Dual-Layer Evaluation Architecture

Dual-Layer Evaluation Architecture

FitAI therefore implements a:

Dual-Layer Model Evaluation System

combining:

  • real neural prediction stability
  • synthetic physiological simulation comparison

This architecture allows the platform to monitor:

  • model drift
  • physiological consistency
  • behavioral stability
  • abnormal prediction deviations
  • recovery trend evolution

Model Health Score

FitAI computes an experimental:

Model Health Score

derived from:

  • stability drift
  • synthetic drift
  • historical prediction variance

The score acts as a lightweight behavioral monitoring signal for neural prediction consistency.

The purpose of the system is not medical validation, but:

  • neural behavior monitoring
  • physiological trend visualization
  • experimental AI evaluation
  • recovery-oriented tracking

Dynamic Visualization System

FitAI includes dynamic physiological dashboards built with:

  • Django
  • JavaScript
  • Chart.js

The visualization layer provides:

  • prediction timelines
  • historical physiological graphs
  • model stability charts
  • explainability displays
  • monitoring dashboards
  • temporal drift visualization
  • s1

Emotional Drift Modeling

stochastic

FitAI contains a stochastic emotional forecasting system inspired by Itô stochastic differential equations.

Mathematical form:

$$dS_t = [\kappa(\theta - S_t) + \mu S_t + alcohol_{drift}]dt + \sigma_{eff}(S_t)dW_t$$

The system models:

  • emotional stress drift
  • nonlinear alcohol influence
  • volatility growth
  • stochastic instability
  • mean reversion dynamics

Alcohol exposure increases:

  • stress drift
  • emotional instability
  • volatility of future emotional states

This module introduces stochastic physiological modeling into the platform.


Training Optimization System

Physiological Signal Flow

FitAI includes a physiological weekly training optimizer.

The optimizer dynamically adjusts:

  • calorie deficit
  • weekly HIIT count
  • recovery load
  • cardiovascular stress
  • recovery penalties

The optimizer considers:

  • HRV
  • sleep quality
  • alcohol exposure
  • blood pressure
  • age
  • training load
  • recovery penalties

The system automatically reduces training intensity when recovery risk becomes elevated.

Hamilton–Jacobi–Bellman Inspired Risk Modeling

FitAI includes a simplified physiological control model inspired by Hamilton–Jacobi–Bellman optimization ideas.

hjb

The system estimates:

  • training risk
  • optimal training intensity
  • short-term physiological trajectory

The model simulates:

  • HRV dynamics
  • sleep recovery dynamics
  • blood pressure response
  • physiological cost minimization

Simplified objective form:

$$J(X,u) = \sum instant\_cost(X_t,u_t)$$

where:

  • (X_t) → physiological state
  • (u_t) → training intensity/control signal

The system searches for lower-risk physiological trajectories across time.

This module acts as a simplified optimal-control inspired recovery system.

Dataset Architecture

FitAI uses a dual-dataset architecture.

Base Physiological Dataset

edited_23_params_realistic.csv

Contains:

  • engineered physiological variables
  • observable biomedical signals
  • synthetic physiological feature generation
  • stable production-oriented training data

Generated using:

  • pandas
  • NumPy
  • physiological feature engineering

Latent Physiological Dataset

Latent Physiological States

edited_23_params_realistic_latent.csv

Experimental hidden-state physiological dataset containing:

  • latent_energy
  • latent_stress
  • latent_recovery
  • latent_rhythm

The latent pipeline introduces:

  • hidden-state physiological representations
  • normalized latent synthesis
  • experimental recovery modeling
  • future research-oriented architecture

FitAI therefore supports architectural switching between:

  • observable physiological learning
  • latent hidden-state augmented learning

The latent dataset pipeline is reserved for future experimental research and advanced model extensions.

Neural Network Architecture

Main architecture:

  • Input: 23 physiological parameters
  • Embedding layer: 48 neurons
  • Hidden layer: 32 neurons
  • Output layer: 8 physiological outputs

Activation functions:

  • Hidden layers → tanh
  • Output constraints → softplus + tanh

Additional features:

  • momentum optimization
  • gradient clipping
  • early stopping
  • normalization scaling
  • physiological output constraints

Model Serialization

The trained model is stored as:

trained_fitness_model_simple.pkl

Serialized components include:

  • neural network weights
  • embeddings
  • normalization statistics
  • output scaling state
  • validation metrics

The utility script:

check_model.py

converts serialized model parameters into a human-readable diagnostic overview.

Testing

The project includes:

  • physiological prediction tests
  • behavioral consistency tests
  • deterministic inference tests
  • validation tests
  • Django form validation tests

Implemented using:

  • pytest

Technology Stack

Backend

  • Python
  • Django
  • NumPy
  • pandas
  • OpenCV
  • SQLite

Machine Learning

  • custom NumPy neural networks
  • explainability analysis
  • stochastic physiological simulation
  • sensitivity analysis
  • physiological monitoring systems

Infrastructure

  • Docker
  • docker-compose
  • pytest

Frontend

  • HTML
  • CSS
  • JavaScript
  • Chart.js

Project Structure

FitAI/
│
├── data/
│   ├── edited_23_params_realistic.csv
│   │   # Expanded physiological dataset generated with pandas feature engineering
│   │
│   ├── edited_23_params_realistic_latent.csv
│   │   # Physiological training dataset augmented with hidden-state latent features
│   │
│   └── gym_members_exercise_tracking.csv
│       # Original dataset downloaded from Kaggle
│
├── fitai/
│   ├── settings.py
│   └── urls.py
│
├── fitness/
│   ├── migrations/
│   │
│   ├── static/
│   │   ├── css/
│   │   └── js/
│   │
│   ├── templates/
│   │   ├── base.html
│   │   ├── history.html
│   │   ├── metrics.html
│   │   ├── onboarding.html
│   │   ├── results.html
│   │   └── update.html
│   │
│   ├── apps.py
│   ├── forms.py
│   ├── urls.py
│   │
│   └── views.py
│       # Core Django application logic integrating onboarding,
│       # physiological prediction, explainability, training optimization,
│       # risk analysis, photo analysis, and model stability metrics
│
├── media/
│   └── photos/
│
├── ml/
│   ├── models/
│   │   ├── check_model.py
│   │   │   # Utility script for converting serialized .pkl model contents
│   │   │   # into a human-readable parameter overview
│   │   │
│   │   └── trained_fitness_model_simple.pkl
│   │       # Serialized trained physiological prediction model
│   │       # with weights and normalization state
│   │
│   ├── emotional_drift.py
│   │   # Stochastic emotional stress forecasting using an
│   │   # Itô-process-inspired physiological drift model
│   │
│   ├── feature_importance.json
│   │   # Feature importance and explainability analysis for model outputs
│   │
│   ├── fit_model_core.py
│   │   # Custom NumPy neural network with physiological output constraints,
│   │   # momentum optimization, early stopping, and feature importance analysis
│   │
│   ├── photo_analysis.py
│   │   # OpenCV-based body proportion analysis and physique classification
│   │   # from user photos
│   │
│   ├── preprocess_dataset.py
│   │   # Physiological dataset expansion and synthetic feature engineering
│   │   # pipeline using pandas and NumPy
│   │
│   ├── preprocess_latent.py
│   │   # Latent physiological feature generation and hidden-state
│   │   # normalization pipeline
│   │
│   ├── train_model.py
│   │   # NumPy neural network training pipeline with physics-based
│   │   # target generation, validation, serialization,
│   │   # and explainability analysis
│   │
│   ├── training_history.json
│   │   # Training configuration, validation metrics, and model metadata
│   │
│   ├── training_optimizer.py
│   │   # Physiological weekly training load optimizer with recovery
│   │   # and cardiovascular risk adjustment
│   │
│   └── training_risk.py
│       # Simplified Hamilton–Jacobi–Bellman-inspired physiological
│       # training risk and intensity optimization model
│
├── tests/
│   ├── test_model.py
│   │   # Pytest-based validation suite for physiological prediction
│   │   # consistency and behavioral sanity checks
│   │
│   └── test_views.py
│       # Input validation tests for Django form and physiological data handling
│
├── .dockerignore
├── .gitignore
├── db.sqlite3
├── docker-compose.yml
├── Dockerfile
├── main.py
├── manage.py
├── pytest.ini
└── requirements.txt


Mitochondrial Energy Dynamics

Experimental visualization of mitochondrial energy behavior, ATP efficiency, recovery energetics, and physiological adaptation mechanisms.

parameters

FitAI explores future physiological modeling concepts involving:

  • ATP production efficiency
  • recovery energetics
  • mitochondrial adaptation
  • oxygen utilization
  • latent energy dynamics
  • physiological resilience modeling

This direction is part of the platform’s long-term research architecture focused on hidden physiological state modeling and adaptive biological intelligence systems.

Research Direction

Future directions include:

  • latent-state physiological learning
  • hidden recovery state modeling
  • nonlinear regression extensions
  • sinusoidal physiological dynamics
  • quaternion-based neural layers
  • physiological hidden-state embeddings
  • advanced optimal-control systems
  • online adaptive learning
  • stochastic recovery simulation

FitAI Philosophy

FitAI was designed not as a generic calorie predictor, but as an experimental physiologically reactive AI system.

The project attempts to combine:

  • machine learning
  • physiological modeling
  • explainability
  • stochastic mathematics
  • optimal control ideas
  • recovery dynamics
  • hidden-state modeling
  • longitudinal monitoring
  • physiological simulation

into a single extensible research-oriented architecture.

About

Physiologically reactive AI research platform with custom neural modeling.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages