Skip to content

MTech-Applied-AI/ml_classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌿 ML Classifier with Flask API

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

πŸ“Œ 1️⃣ Setting up the Environment

To isolate dependencies, set up a virtual environment:

python -m venv .venv
source .venv/bin/activate  # For macOS

πŸ“Œ 2️⃣ Install Dependencies

To isolate dependencies, set up a virtual environment:

pip install -r requirements.txt

πŸ“Œ 3️⃣ Train the Model

Before running the API, train the classifier using the following command:

python train.py

πŸ“Œ 4️⃣ Run the Flask API

start the Flask server:

python app.py

πŸ“Œ 5️⃣ API Endpoints

πŸš€ 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"
}

πŸ“Š GET /get-status - Get train-test split details

curl -X GET http://127.0.0.1:5000/get-status
{
  "train_count": 120,
  "test_count": 30
}

Releases

No releases published

Packages

No packages published

Languages