A FastAPI-based Machine Learning project that predicts vehicle fuel consumption using a regression model trained on the FuelConsumption dataset.
This project demonstrates the full pipeline — data preprocessing, model training, serialization with Joblib, and API deployment using FastAPI.
This API allows users to input numeric vehicle parameters (like engine size, cylinders, or CO2 emissions) and get predicted fuel consumption values instantly.
- FastAPI – Backend framework
- Scikit-learn – Model training
- Joblib – Model serialization
- Pydantic – Data validation
- Uvicorn – ASGI server for deployment
├── api.py # FastAPI app
├── model/
│ └── model.pkl # Trained model
├── notebook.ipynb
├── data/
│ └── FuelConsumption.csv
├── requirements.txt
└── README.md
Request Body
{
"feature1": 5.3,
"feature2": 120.5
}Response
{
"prediction": 7.84
}git clone https://github.com/sameer-at-git/Fuel-Consumption-Prediction-API-using-Linear-Regression-and-FastAPI.git
cd Fuel-Consumption-Prediction-API-using-Linear-Regression-and-FastAPIpython -m venv venv
source venv/bin/activate # (Linux/Mac)
venv\Scripts\activate # (Windows)pip install -r requirements.txtuvicorn app.api:app --reloadAccess the docs:
👉 http://127.0.0.1:8000/docs
The notebook notebook.ipynb covers:
- Dataset exploration
- Feature engineering
- Model training & evaluation
- Saving model using Joblib
- Hugging Face Spaces (with FastAPI)
- Render
- Railway.app
- Vercel (with ASGI adapter)
Md. Sameer Sayed
📧 mdsameersayed0@gmail.com
🌐 GitHub
This project is released under the MIT License.

