This project implements a Decision Tree Classifier using the Iris Dataset and exposes it via a Flask API.
The API supports:
- π
/predictβ Predict the class of an Iris flower - π
/get-statusβ Get the train-test split counts
To isolate dependencies, set up a virtual environment:
python -m venv .venv
source .venv/bin/activate # For macOSTo isolate dependencies, set up a virtual environment:
pip install -r requirements.txtBefore running the API, train the classifier using the following command:
python train.pystart the Flask server:
python app.pyπ POST /predict - Make a classification
curl -X POST http://127.0.0.1:5000/predict \
-H "Content-Type: application/json" \
-d '{"sepal_length": 5.1, "sepal_width": 3.5, "petal_length": 1.4, "petal_width": 0.2}'
{
"prediction": "Iris-setosa"
}
curl -X GET http://127.0.0.1:5000/get-status{
"train_count": 120,
"test_count": 30
}