{"id":25193829,"url":"https://github.com/itzdineshx/iris-flower-classification","last_synced_at":"2026-04-29T06:38:52.130Z","repository":{"id":275447357,"uuid":"926109909","full_name":"itzdineshx/Iris-flower-classification","owner":"itzdineshx","description":"A web application for predicting Iris flower species using machine learning models with Gradio UI. Users can input measurements and receive predictions along with a representative image.","archived":false,"fork":false,"pushed_at":"2025-02-21T22:53:44.000Z","size":30448,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T13:45:12.554Z","etag":null,"topics":["gradio","iris-dataset","iris-flower-classification","iris-recognition","jupyter-notebook","knn-classification","logistic-regression","machine-learning","python","svm-classifier","web-app"],"latest_commit_sha":null,"homepage":"https://huggingface.co/spaces/DINESH-X/Iris-Flower-classifier","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itzdineshx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-02T15:24:27.000Z","updated_at":"2025-02-21T22:53:47.000Z","dependencies_parsed_at":"2025-02-21T21:55:56.742Z","dependency_job_id":null,"html_url":"https://github.com/itzdineshx/Iris-flower-classification","commit_stats":null,"previous_names":["itzdineshx/iris-flower-classification"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/itzdineshx/Iris-flower-classification","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzdineshx%2FIris-flower-classification","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzdineshx%2FIris-flower-classification/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzdineshx%2FIris-flower-classification/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzdineshx%2FIris-flower-classification/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itzdineshx","download_url":"https://codeload.github.com/itzdineshx/Iris-flower-classification/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itzdineshx%2FIris-flower-classification/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261795334,"owners_count":23210620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gradio","iris-dataset","iris-flower-classification","iris-recognition","jupyter-notebook","knn-classification","logistic-regression","machine-learning","python","svm-classifier","web-app"],"created_at":"2025-02-09T23:22:41.562Z","updated_at":"2026-04-29T06:38:52.102Z","avatar_url":"https://github.com/itzdineshx.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Iris Flower Classification: A Comprehensive Comparison of Multiple Models with Confidence Prediction\n\n![App Animation](img/iris.gif) \n\n\n*Watch the interactive demo in action!*\n\n## **Try App:** [Link](https://huggingface.co/spaces/DINESH-X/Iris-Flower-classifier)\n\n---\n\n## **Overview**\n\n![iris flowers](img/cover.png)\n\nThis project demonstrates the classification of the **Iris Flower dataset** using five different machine learning algorithms:\n- **K-Nearest Neighbors (KNN)**\n- **Support Vector Machine (SVM)**\n- **Logistic Regression**\n- **Decision Tree**\n- **Random Forest**\n\nEach model predicts the species of an iris flower based on four measurements (sepal length, sepal width, petal length, petal width) and now also provides a confidence percentage with its prediction. The interactive Gradio app allows you to experiment with different inputs and see not only the predicted species but also a representative flower image.\n\n---\n\n## **Dataset**\n- **Name:** Iris dataset\n- **Source:** [Scikit-learn](https://scikit-learn.org/)\n- **Number of Samples:** 150\n- **Features:** \n  - Sepal Length (cm)\n  - Sepal Width (cm)\n  - Petal Length (cm)\n  - Petal Width (cm)\n- **Target Classes:**\n  - **Iris-setosa**\n  - **Iris-versicolor**\n  - **Iris-virginica**\n\n---\n\n## **Project Goals**\n- Compare the performance of **KNN**, **SVM**, **Logistic Regression**, **Decision Tree**, and **Random Forest** on the Iris dataset.\n- Provide detailed prediction outputs with confidence percentages.\n- Evaluate the models using metrics such as **accuracy**, **precision**, **recall**, and **F1-score**.\n- Create an interactive demo with Gradio that displays predictions and corresponding flower images.\n- Deploy the app for free using Hugging Face Spaces.\n\n---\n\n## **Model Comparison**\n1. **K-Nearest Neighbors (KNN):**  \n   Classifies based on the majority vote among nearest neighbors.\n2. **Support Vector Machine (SVM):**  \n   Constructs optimal hyperplanes (with probability estimates enabled) for class separation.\n3. **Logistic Regression:**  \n   Uses a logistic function to predict class probabilities.\n4. **Decision Tree:**  \n   Uses a tree-like model of decisions for classification.\n5. **Random Forest:**  \n   An ensemble method based on multiple decision trees for robust predictions.\n\n![Model Comparison Animation](img/iris_models_comp_adv.png)  \n\n---\n\n## **Project Structure**\n\n```\nDirectory structure:\n└── itzdineshx-iris-flower-classification/\n    ├── README.md\n    ├── LICENSE\n    ├── requirements.txt\n    ├── Data/\n    │   ├── Iris.csv\n    │   └── database.sqlite\n    ├── img/\n    │   ├── iris_virginica.webp\n    │   └── flower_img/\n    ├── models/\n    │   ├── iris_knn_model.pkl\n    │   ├── iris_logreg_model.pkl\n    │   ├── iris_svm_model.pkl\n    │   └── iris_models_tuned/\n    │       ├── dtc_model.joblib\n    │       ├── knn_model.joblib\n    │       ├── label_encoder.joblib\n    │       ├── logreg_model.joblib\n    │       ├── rfc_model.joblib\n    │       ├── scaler.joblib\n    │       └── svm_model.joblib\n    ├── notebook/\n    │   ├── IRIS_FLOWERS_CLASSIFICATION.ipynb\n    │   └── IRIS_FLOWERS_CLASSIFICATION_2_0.ipynb\n    └── src/\n        ├── advanced_app.py\n        ├── app.py\n        └── .gradio/\n            └── certificate.pem\n\n\n```\n\n---\n\n## **Installation**\n\nClone this repository to your local machine:\n\n```bash\ngit clone https://github.com/itzdineshx/Iris-Flower-Classification.git\ncd Iris-Flower-Classification\n```\n\nInstall the required dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\n---\n\n## **Dependencies**\n\nThe project depends on the following libraries:\n- **Scikit-learn:** For machine learning models.\n- **Pandas:** For data manipulation.\n- **NumPy:** For numerical operations.\n- **Matplotlib \u0026 Seaborn:** For data visualization.\n- **Joblib:** For model serialization.\n- **Gradio:** For building the interactive web app.\n- **Pillow:** For image processing.\n\nTo install these dependencies, run:\n\n```bash\npip install scikit-learn pandas numpy matplotlib seaborn joblib gradio pillow\n```\n\n---\n\n## **Usage**\n\n### **Training and Saving Models**\nThe project includes a Jupyter Notebook (`IRIS_FLOWERS_CLASSIFICATION.ipynb`) and (`IRIS_FLOWERS_CLASSIFICATION_2.0.ipynb`) that demonstrates:\n- Loading and preprocessing the Iris dataset.\n- Visulization of Data\n- Training the five classifiers.\n- Evaluating the models using various classification metrics.\n- Saving the trained models and scaler using Joblib.\n\nExample code to save the models:\n```python\nimport joblib\n\njoblib.dump(knn, 'models/iris_knn_model.joblib')\njoblib.dump(svm, 'models/iris_svm_model.joblib')\njoblib.dump(logreg, 'models/iris_logreg_model.joblib')\njoblib.dump(dtc, 'models/iris_dtc_model.joblib')\njoblib.dump(rfc, 'models/iris_rfc_model.joblib')\njoblib.dump(scaler, 'models/scaler.joblib')\njoblib.dump(le, 'models/label_encoder.joblib')\n```\n\n### **Launching the App**\nFrom the `src` folder, run the Gradio app with:\n```bash\npython app.py\n```\nThis will start the Gradio interface, open a new browser tab, and display the interactive app.\n\n---\n\n## **App Demo: Interactive Predictions with Confidence**\n\n\n![App Interface](img/iris_app_interface.png)  \n\nThe interactive demo allows you to:\n- **Input Measurements:** Enter sepal and petal dimensions.\n- **Select a Model:** Choose one of the five available classifiers.\n- **View Predictions:** See the predicted Iris species along with a confidence percentage.\n- **Display Image:** View a representative image of the predicted flower.\n\n**Example Inputs:**\n```python\nexamples=[\n    [5.1, 3.5, 1.4, 0.2, \"KNN\"],              # Typical Iris-setosa\n    [5.9, 3.0, 5.1, 1.8, \"Logistic Regression\"],  # Likely Iris-versicolor\n    [6.3, 2.8, 5.1, 1.5, \"SVM\"],               # Typical Iris-virginica\n    [6.7, 3.0, 5.2, 2.3, \"Decision Tree\"],     # Another Iris-virginica example\n    [5.8, 2.7, 4.1, 1.0, \"Random Forest\"]      # Borderline case\n]\n```\nThese examples are available directly in the Gradio interface to help you get started.\n\n![App Usage](img/iris_pred_versicolor.png)  \n\n\n---\n\n## **Results**\n\nThe models have been evaluated on the Iris dataset using various metrics. Below are sample classification reports for each model. Note that the results may vary slightly depending on the train/test splits.\n\n### **KNN Classification Report**\n\n```\n              precision    recall  f1-score   support\nIris-setosa       1.00      1.00      1.00        10\nIris-versicolor   1.00      1.00      1.00         9\nIris-virginica    1.00      1.00      1.00        11\n```\n\n---\n\n### **SVM Classification Report**\n\n```\n              precision    recall  f1-score   support\nIris-setosa       1.00      1.00      1.00        10\nIris-versicolor   1.00      0.89      0.94         9\nIris-virginica    0.92      1.00      0.96        11\n```\n\n---\n\n### **Logistic Regression Classification Report**\n\n```\n              precision    recall  f1-score   support\nIris-setosa       1.00      1.00      1.00        10\nIris-versicolor   1.00      1.00      1.00         9\nIris-virginica    1.00      1.00      1.00        11\n```\n\n---\n\n### **Decision Tree and Random Forest Classification Report**\n\n```\n              precision    recall  f1-score   support\nIris-setosa       1.00      1.00      1.00        10\nIris-versicolor   1.00      1.00      1.00         9\nIris-virginica    1.00      1.00      1.00        11\n```\n\n---\n\n## **Deployment**\nThe Gradio app has been deployed on Hugging Face Spaces for free hosting. You can access it here:\n[https://huggingface.co/spaces/DINESH-X/Iris-Flower-classifier](https://huggingface.co/spaces/DINESH-X/Iris-Flower-classifier)\n\n---\n\n## **Contributing**\nContributions are welcome! If you have suggestions or improvements, please consider contributing:\n- **Bug Fixes \u0026 Feature Enhancements**\n- **Model Improvements \u0026 New Metrics**\n- **UI/UX Enhancements**\n- **Documentation \u0026 Examples**\n\n### **How to Contribute**\n1. Fork the repository.\n2. Clone fork:\n   ```bash\n   git clone https://github.com/itzdineshx/Iris-flower-classification.git\n   ```\n3. Create a new branch:\n   ```bash\n   git checkout -b feature/new-feature\n   ```\n4. Commit changes:\n   ```bash\n   git commit -m \"Add new feature\"\n   ```\n5. Push to your branch:\n   ```bash\n   git push origin feature/new-feature\n   ```\n6. Open a Pull Request describing your changes.\n\n---\n\n## **Author**\n**DINESH S**  \n\u003ch3\u003eConnect with me:\u003c/h3\u003e\n\u003ca href=\"https://www.linkedin.com/in/dinesh-x/\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://cdn-icons-png.flaticon.com/512/174/174857.png\" alt=\"LinkedIn\" style=\"width:32px;\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/itzdineshx/Iris-flower-classification\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/9/91/Octicons-mark-github.svg\" alt=\"GitHub\" style=\"width:32px;\"\u003e\n\u003c/a\u003e\n\u003ca href=\"mailto:personalaccdinesh@gmail.com\" target=\"_blank\"\u003e\n  \u003cimg src=\"https://cdn-icons-png.flaticon.com/512/732/732200.png\" alt=\"Gmail\" style=\"width:32px;\"\u003e\n\u003c/a\u003e\n\n\n---\n\n## **License**\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzdineshx%2Firis-flower-classification","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitzdineshx%2Firis-flower-classification","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitzdineshx%2Firis-flower-classification/lists"}