🔥 Calories Burned Predictor

A lightweight PyTorch regression model that predicts calories burned during a workout from basic biometrics and exercise stats.
Built as part of the learn-pytorch-2026 project.

Live demo → 🤗 panchsan123/calories-burned-demo


Model Description

CalorieModel is a fully-connected feedforward neural network trained for regression on the Kaggle Calories Burned dataset.
It takes 7 input features and outputs a single continuous value (calories burned in kcal).


Architecture

Input(7)
  → Linear(128) → ReLU → Dropout(0.2)
  → Linear(64)  → ReLU → Dropout(0.2)
  → Linear(32)  → ReLU → Dropout(0.2)
  → Linear(1)                           ← no activation (raw regression output)
Property Value
Total parameters ~10,625
Loss function MSELoss
Optimizer Adam (lr = 0.001)
Scheduler ReduceLROnPlateau (patience=10, factor=0.5)
Early stopping patience = 15 epochs

Input Features

Inputs must be standardized using the scaler_mean and scaler_std arrays stored in config.json before inference.

# Feature Type Description
0 Gender int 1 = Male, 0 = Female
1 Age float Years
2 Height float Centimetres
3 Weight float Kilograms
4 Duration float Workout duration in minutes
5 Heart_Rate float Average BPM during workout
6 Body_Temp float Body temperature in °C

Training Details

Setting Value
Dataset Kaggle — "Calories Burned during Exercise"
Dataset size 15,000 rows, 0 missing values
Split 70% train / 15% val / 15% test
Preprocessing StandardScaler fit on train only
Max epochs 150
Actual stop Epoch 70 (early stopping)
Batch size 64
LR schedule 0.001 → 0.0005 (epoch ~30) → 0.00025 (epoch ~55)
Hardware Google Colab T4 GPU
Seed 42

Evaluation Results (Test Set)

Metric Value Meaning
RMSE 1.79 kcal Average prediction error within 1.79 calories
MAE 1.23 kcal Typical prediction off by 1.23 calories
0.9992 Model explains 99.92% of variance in calorie burn

Files in this Repo

File Format Use
best_model.pt PyTorch state_dict Reload and fine-tune in Python
model_scripted.pt TorchScript Android / Java via PyTorch Mobile
model.onnx ONNX Maximum portability — C++, Java, web, edge
config.json JSON Scaler params, feature order, metrics

How to Use

Python (TorchScript)

import torch, json, numpy as np
from huggingface_hub import hf_hub_download

# Download model and config
config_path = hf_hub_download("panchsan123/calories-burned-predictor", "config.json")
model_path  = hf_hub_download("panchsan123/calories-burned-predictor", "model_scripted.pt")

with open(config_path) as f:
    cfg = json.load(f)

model = torch.jit.load(model_path, map_location="cpu")
model.eval()

def predict_calories(gender, age, height, weight, duration, heart_rate, body_temp):
    gender_encoded = 1 if gender.lower() == "male" else 0
    raw    = np.array([[gender_encoded, age, height, weight,
                        duration, heart_rate, body_temp]], dtype=np.float32)
    mean   = np.array(cfg["scaler_mean"])
    std    = np.array(cfg["scaler_std"])
    scaled = (raw - mean) / std

    with torch.no_grad():
        result = model(torch.FloatTensor(scaled)).item()
    return round(result, 1)

# Example
print(predict_calories("Male", 28, 175, 72, 30, 145, 40.5))
# → ~260.4 kcal

config.json structure

{
  "features":     ["Gender", "Age", "Height", "Weight", "Duration", "Heart_Rate", "Body_Temp"],
  "scaler_mean":  [...],
  "scaler_std":   [...],
  "gender_map":   {"male": 1, "female": 0},
  "architecture": {"hidden": [128, 64, 32], "dropout": 0.2},
  "metrics":      {"rmse": 1.79, "mae": 1.23, "r2": 0.9992}
}

Limitations

  • Trained on a single Kaggle dataset — predictions may be less accurate for athletes or people with unusual physiology
  • No activity type input (running vs cycling vs weightlifting are all treated the same)
  • Body temperature during exercise is not commonly measured — the live demo uses a pre-filled typical value

Citation

@misc{calories-burned-predictor-2026,
  author  = {panchsan123},
  title   = {Calories Burned Predictor},
  year    = {2026},
  url     = {https://huggingface.co/panchsan123/calories-burned-predictor}
}
Downloads last month
9
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Evaluation results

  • RMSE (kcal) on Calories Burned during Exercise (Kaggle)
    self-reported
    1.790
  • MAE (kcal) on Calories Burned during Exercise (Kaggle)
    self-reported
    1.230
  • on Calories Burned during Exercise (Kaggle)
    self-reported
    0.999