{"id":24708537,"url":"https://github.com/benami171/ml_knn_decision-trees","last_synced_at":"2025-06-30T20:38:38.206Z","repository":{"id":272916452,"uuid":"917847795","full_name":"benami171/ML_kNN_Decision-trees","owner":"benami171","description":"A ml implementation comparing Decision Trees and k-Nearest Neighbors (k-NN) algorithms for Iris flower classification. Features comprehensive analysis of different approaches including brute-force and entropy-based decision trees, along with k-NN using multiple distance metrics. ","archived":false,"fork":false,"pushed_at":"2025-01-20T13:51:05.000Z","size":414,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-20T14:41:17.098Z","etag":null,"topics":["classification","cross-validation","data-analysis","decision-trees","iris-dataset","k-nearest-neighbours","machine-learning","nearest-neighbors","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benami171.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-01-16T18:56:27.000Z","updated_at":"2025-01-20T13:51:06.000Z","dependencies_parsed_at":"2025-01-20T14:41:18.312Z","dependency_job_id":null,"html_url":"https://github.com/benami171/ML_kNN_Decision-trees","commit_stats":null,"previous_names":["benami171/ml_ex_03","benami171/ml_knn_decision-trees"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benami171%2FML_kNN_Decision-trees","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benami171%2FML_kNN_Decision-trees/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benami171%2FML_kNN_Decision-trees/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benami171%2FML_kNN_Decision-trees/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benami171","download_url":"https://codeload.github.com/benami171/ML_kNN_Decision-trees/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244913316,"owners_count":20530817,"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":["classification","cross-validation","data-analysis","decision-trees","iris-dataset","k-nearest-neighbours","machine-learning","nearest-neighbors","python"],"created_at":"2025-01-27T06:33:47.204Z","updated_at":"2025-03-22T06:14:54.873Z","avatar_url":"https://github.com/benami171.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Iris 🌸 Classification using Decision Trees and k-NN\n\nA comprehensive machine learning project implementing and comparing Decision Trees and k-Nearest Neighbors (k-NN) algorithms for classifying Iris flowers. This project focuses on binary classification between Versicolor and Virginica species using their petal measurements.\n\n## 📑 Table of Contents\n\n- [Project Overview](#project-overview)\n- [Key Features](#key-features)\n- [📂 Project Structure](#project-structure)\n- [Installation](#installation)\n- [📊 Results and Analysis](#results-and-analysis)\n  - [k-NN Performance Analysis](#k-nn-performance-analysis)\n  - [Decision Tree Comparison](#decision-tree-comparison)\n- [Usage](#usage)\n- [🔬 Technical Details](#technical-details)\n  - [Implemented Algorithms](#implemented-algorithms)\n  - [Performance Metrics](#performance-metrics)\n- [🤝 Contributing](#contributing)\n- [📄 License](#license)\n\n## Project Overview\n\nThis project implements and analyzes two fundamental machine learning algorithms:\n1. k-Nearest Neighbors (k-NN) with various distance metrics\n2. Decision Trees with two different splitting strategies (Brute-force and Binary Entropy)\n\nThe implementation uses the Iris dataset, specifically focusing on distinguishing between Versicolor and Virginica species using only their second and third features.\n\n## Key Features\n\n- **Advanced k-NN Implementation**:\n  - Multiple k values (1, 3, 5, 7, 9)\n  - Different distance metrics (L1, L2, L∞)\n  - Comprehensive error analysis across parameters\n  \n- **Dual Decision Tree Approaches**:\n  - Brute-force approach constructing all possible trees\n  - Binary entropy-based splitting strategy\n  - Visualizations of tree structures and decision boundaries\n\n## 📂 Project Structure\n\n```bash\n.\n├── models/                  # Core ML model implementations\n│   ├── __init__.py\n│   ├── decision_trees.py   # Decision tree algorithms\n│   └── knn.py             # k-NN implementation\n├── results/                # Generated visualizations\n│   ├── decision_tree_errors.png\n│   ├── decision_tree_figure1_visualization.png\n│   ├── decision_tree_figure2_visualization.png\n│   └── k-NN_errors.png\n├── data_utils.py          # Data handling utilities\n├── main.py               # Main execution script\n├── metrics.py            # Evaluation metrics\n└── visualization.py      # Visualization tools\n```\n\n## Installation\n\n1. **Clone the repository**:\n   ```bash\n   git clone https://github.com/yourusername/iris-classification.git\n   cd iris-classification\n   ```\n\n2. **Set up a virtual environment** (recommended):\n   ```bash\n   python -m venv venv\n   source venv/bin/activate  # On Windows use: venv\\Scripts\\activate\n   ```\n\n3. **Install dependencies**:\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n## 📊 Results and Analysis\n\n### k-NN Performance Analysis\n\nThe k-NN implementation was tested with various parameters:\n- k values: 1, 3, 5, 7, 9\n- Distance metrics: L1 (Manhattan), L2 (Euclidean), L∞ (Chebyshev)\n\n\u003e 💡 **Key Findings**:\n\u003e - Higher k values generally resulted in more stable predictions\n\u003e - L2 distance metric showed slightly better performance\n\u003e - Best performance achieved with k=9 using L2 distance\n\n![k-NN Error Analysis](results/k-NN_errors1.png)\n\n### Decision Tree Comparison\n\nTwo decision tree implementations were compared:\n\n1. **Brute-Force Approach** 🔍:\n   - Error rate: 5.00%\n\n2. **Entropy-Based Approach** 🎯:\n   - Error rate: 7.00%\n\n![Decision Tree Structures](results/decision_tree_figure1_visualization.png)\n![Decision Boundaries](results/decision_tree_figure2_visualization.png)\n\n## Usage\n\nRun the main analysis script:\n```bash\npython main.py\n```\n\nThis will execute:\n1. 📥 Load and preprocess the Iris dataset\n2. 📊 Perform k-NN analysis with various parameters\n3. 🌳 Generate decision trees using both approaches\n4. 📈 Create visualizations and error analysis\n\n## 🔬 Technical Details\n\n### Implemented Algorithms\n\n1. **k-Nearest Neighbors**:\n   - Custom implementation with multiple distance metrics\n   - Parameter evaluation framework\n   - Cross-validation with 100 iterations\n\n2. **Decision Trees**:\n   - Brute-force tree construction\n   - Entropy-based splitting\n   - Visualization of tree structures and decision boundaries\n\n### Performance Metrics\n\nThe project employs several metrics for evaluation:\n- Classification error rates\n- Training vs. Test set performance\n- Error difference analysis\n\n## 🤝 Contributing\n\nWe welcome contributions! Please feel free to submit a Pull Request. For major changes:\n1. 🍴 Fork the repository.\n2. 🌿 Create a new branch (`git checkout -b feature-branch`).\n3. 💡 Commit your changes (`git commit -m 'Add new feature'`).\n4. 📤 Push to the branch (`git push origin feature-branch`).\n5. 🔍 Open a Pull Request.\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenami171%2Fml_knn_decision-trees","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenami171%2Fml_knn_decision-trees","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenami171%2Fml_knn_decision-trees/lists"}