A Django web application that predicts the species of an Iris flower based on its measurements, using a trained Random Forest model.
This project exposes a web form and a REST API endpoint to classify Iris flowers into one of three species:
- Iris setosa
- Iris versicolor
- Iris virginica
It uses a RandomForestClassifier trained on the classic Iris dataset from scikit-learn.
git clone https://github.com/Kenkyoo/django-iris-predictor.git
cd mlapppython3 -m venv venv
source venv/bin/activatepip install -r requirements.txtpython train.pypython manage.py runserverVisit http://localhost:8000 in your browser.
docker build -t mlapp .docker run -p 8000:8000 mlappVisit http://localhost:8000 in your browser.
- Push your code to GitHub (make sure
predictor/model/iris_rf.joblibis included). - Go to render.com and create a new Web Service.
- Connect your GitHub repository.
- Render will detect the
Dockerfileautomatically. - Click Deploy.
Endpoint: POST /api/predict/
Content-Type: application/json
{
"sepal_length": 5.1,
"sepal_width": 3.5,
"petal_length": 1.4,
"petal_width": 0.2
}{
"class_index": 0,
"class_name": "setosa",
"probabilities": {
"setosa": 0.980,
"versicolor": 0.015,
"virginica": 0.005
}
}curl -X POST http://localhost:8000/api/predict/ \
-H "Content-Type: application/json" \
-d '{"sepal_length": 5.1, "sepal_width": 3.5, "petal_length": 1.4, "petal_width": 0.2}'- Python 3.12
- Django
- scikit-learn
- Gunicorn
- Docker
- Bulma CSS