← Back to list

Predicting Workout Ratings with Machine Learning: A Practical End-to-End Guide

From a gym dataset to a deployed model, step by step.

Prashant Anand · 2026-05-30 09:46 · 0 claps · 4.5 min read
#artificial-intelligence #random-forest #linear-regression #machine-learning #mlops
Open on Medium ↗
Wiki topics: OPS · LLMOps & Inference ML · Machine Learning AI · AI · General GEN · Genomics & Sequencing EDU · Education & Learning 💪 · Fitness & Wellness

Predicting Workout Ratings with Machine Learning: A Practical End-to-End Guide

From a gym dataset to a deployed model, step by step.

If you’ve ever wondered whether data science and fitness could overlap in a meaningful way, this project is your answer. In this post, I’ll walk you through how I built a machine learning pipeline to predict workout ratings using the Mega Gym Dataset, covering everything from raw data to a saved, callable model.

The Problem Exercise platforms and fitness apps are packed with workouts. But how do you know which ones are actually worth your time? Ratings are one signal but can we predict them? If we can model what makes an exercise well rated based on its attributes (type, targeted body part, equipment, difficulty), we can surface better recommendations and understand what quality workouts have in common.

That’s the question this project tries to answer.

We’re working with megaGymDataset.csv, which contains entries for a wide range of exercises. Key columns include:

  • Title — Exercise name (e.g., Push Ups, Deadlifts)
  • Desc — Description of the exercise
  • Type — Strength, Cardio, Stretching, etc.
  • BodyPart — Chest, Back, Legs, etc.
  • Equipment — Barbell, Dumbbell, None, etc.
  • Level — Beginner, Intermediate, Expert
  • Rating — The target variable (a numeric score)
  • RatingDesc — Text descriptor of the rating (Good, Great, etc.)

Plus numeric biometric features: Age, Weight, Height, Max/Avg/Resting BPM, Session Duration, Calories Burned, Fat Percentage, Water Intake.

Step 1: Data Cleaning and Preprocessing

The first step in any ML project is making sure your data is in shape. Here’s the approach:

Handling Missing Values

For numeric columns, we used mean imputation — a straightforward strategy that keeps the dataset complete without introducing too much bias:

Feature Selection

We selected a core set of numeric features most likely to influence workout quality :

num_features = [“Age”, “Weight”, “Height”, “Max_BPM”, “Avg_BPM”“Resting_BPM”, “Session_Duration”, “Calories_Burned”, “Fat_Percentage”, “Water_Intake”]

Scaling

Raw numeric values at different scales can mislead distance-based models. We applied StandardScaler to normalize them:

Step 2: Encoding Categorical Features

Scikit-learn models don’t speak strings we need to convert categorical columns to numbers. LabelEncoder does this cleanly:

One important thing to note: we store each encoder in a dictionary. This is critical for inference ,you need the exact same mapping when making predictions on new data.

Step 3: Defining Features and Target

X is our feature matrix, y is what we're predicting: the workout rating.

Step 4: Train-Test Split

Standard 80/20 split to evaluate model generalization:

Step 5: Training and Comparing Models

We tested three models to find the best one:

Why these three?

Random Forest came out on top , as it typically does on structured tabular data. Its ensemble of decision trees reduces variance and handles mixed feature types well.

Step 6: Saving the Model

Once we identify the winner, we save it for future use.

Step 7: Making Predictions on New Data

Here’s where things get practical. Say you want to predict the rating for Push Ups:

One subtle but important detail: we check if the value exists in the encoder’s known classes before transforming. If a new exercise type appears at inference time that wasn’t in training data, we assign it -1 instead of crashing. This is the kind of defensive coding that separates prototypes from production-grade pipelines.

Key Takeaways

1. Always save your encoders alongside your model. If you re-fit the encoder at inference time, the integer mappings will be different and your predictions will be garbage.

2. Handle unseen categories explicitly. Real-world data will always throw you curveballs. The -1 fallback is a simple but effective guard.

3. Compare models, don’t just pick one. Linear Regression is a solid baseline that exposes whether your features have real predictive signal. Only reach for complex models after confirming the baseline works.

4. Standardization matters for some models, not others. Random Forests are scale-invariant, but it’s good practice to scale anyway — especially if you plan to try other models later.

What’s Next?

This pipeline is a strong foundation. Some natural next steps:

  • Hyperparameter tuning with GridSearchCV or RandomizedSearchCV to squeeze more performance out of Random Forest
  • Feature importance analysis to understand which attributes actually drive ratings
  • Trying gradient boosting (XGBoost, LightGBM) as a potentially stronger alternative
  • Building a simple API with FastAPI or Flask to serve predictions in real time

If you’re learning machine learning, projects like this are the fastest way to level up. You touch every stage of the pipeline: cleaning, encoding, scaling, training, evaluating, saving, and serving. Each step has its own gotchas, and working through them is worth more than any tutorial.

Full code on GitHub: github.com/Prashantanand2811/Predicting-Workout-Ratings-with-Machine-Learning


메타데이터
post_id
61abca2b7e70
slug
predicting-workout-ratings-with-machine-learning-a-practical-end-to-end-guide-61abca2b7e70
url
https://medium.com/@prashant.anand206/predicting-workout-ratings-with-machine-learning-a-practical-end-to-end-guide-61abca2b7e70
canonical_url
https://medium.com/@prashant.anand206/predicting-workout-ratings-with-machine-learning-a-practical-end-to-end-guide-61abca2b7e70
author_url
https://medium.com/@prashant.anand206
status
ok
fetched_at
2026-06-16 19:09:56