Simple PyTorch-based calorie prediction using cereal nutrition data.
Predict cereal calories from nutritional features using:
- CLI commands
- Python API calls
- Trained PyTorch models
- Train calorie prediction model from cereal nutrition data
- Save/load PyTorch models
- CLI predictions
- Python API predictions
- Loss plotting
- MAE evaluation
- Simple custom feature parser
Clone the repo:
git clone https://github.com/poti1/cereal-ml.git
cd cereal-mlInstall dependencies:
pip install -r requirements.txtTrain the model:
./cereal.py --trainExample output:
Example training metrics:
Epoch 1/10 loss: 104.8351 val_loss: 111.3147
...
Epoch 10/10 loss: 25.8951 val_loss: 27.3140
mae: 28.50
Run predictions directly from the command line:
./cereal.py --data 'sugars=3, protein=5'Example:
Use the predictor directly in Python:
import cereal
cereal.predict('fat=10, sodium=20, carbo=15')Example:
| Input | Predicted Calories |
|---|---|
| sugars=3, protein=5 | 71 |
| fat=10, sodium=20, carbo=15 | 268 |
Generate a training loss plot:
./cereal.py --plotThis creates:
loss.png
The trained model is saved as:
cereal.pt
- Python
- PyTorch
- pandas
- matplotlib
- scikit-learn
This project was built to practice:
- ML training pipelines
- Regression models
- Feature parsing
- Model serialization
- CLI + Python interfaces
- End-to-end ML workflows
MIT



