This project implements an Iris flower classification API using FastAPI.
It uses a Logistic Regression model trained on the Iris dataset to predict flower species.
- Train/test split with scaling
- Logistic Regression model
- Saved model (
iris_model.pkl
) + scaler (scaler.pkl
) - FastAPI endpoints:
/
→ Health check/predict
→ Predict iris species/model-info
→ Model metadata
Iris Project/
│── iris_model.ipynb
│── iris_model.pkl
│── scaler.pkl
│── main.py
│── requirements.txt
│── README.md
# Clone repository
git clone <repo-link>
cd "Iris Project"
# Install dependencies
pip install -r requirements.txt
# Run API
uvicorn main:app --reload
Visit:
- Swagger docs → http://127.0.0.1:8000/docs
- Example request:
{
"sepal_length": 5.1,
"sepal_width": 3.5,
"petal_length": 1.4,
"petal_width": 0.2
}
Response:
{
"prediction": "Iris-setosa",
"confidence": 0.987
}
- Python 3.10+
- FastAPI
- Uvicorn
- scikit-learn
- Pandas
- Numpy
- Joblib