{"id":24779068,"url":"https://github.com/aswajith7077/decisiontreepredictor","last_synced_at":"2026-02-11T08:08:42.044Z","repository":{"id":272915569,"uuid":"870406798","full_name":"Aswajith7077/DecisionTreePredictor","owner":"Aswajith7077","description":"A Custom Decision Tree Classifier using CART Algorithm. Utilizes a custom Data handler class for pre-processing the data. Generated decision trees as Python snippets for predictions.","archived":false,"fork":false,"pushed_at":"2025-01-17T13:32:57.000Z","size":43,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-12T04:32:01.219Z","etag":null,"topics":["decision-tree-classifier","machine-learning","object-oriented-programming","pandas","python","streamlit"],"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/Aswajith7077.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,"zenodo":null}},"created_at":"2024-10-10T01:36:10.000Z","updated_at":"2025-01-17T13:34:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"bb0e4d34-b148-471f-a6c9-4100e786caf1","html_url":"https://github.com/Aswajith7077/DecisionTreePredictor","commit_stats":null,"previous_names":["aswajith7077/decisiontreepredictor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Aswajith7077/DecisionTreePredictor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aswajith7077%2FDecisionTreePredictor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aswajith7077%2FDecisionTreePredictor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aswajith7077%2FDecisionTreePredictor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aswajith7077%2FDecisionTreePredictor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aswajith7077","download_url":"https://codeload.github.com/Aswajith7077/DecisionTreePredictor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aswajith7077%2FDecisionTreePredictor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29329649,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T06:13:03.264Z","status":"ssl_error","status_checked_at":"2026-02-11T06:12:55.843Z","response_time":97,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["decision-tree-classifier","machine-learning","object-oriented-programming","pandas","python","streamlit"],"created_at":"2025-01-29T09:35:22.232Z","updated_at":"2026-02-11T08:08:42.039Z","avatar_url":"https://github.com/Aswajith7077.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\n\n# CART Classifier with Streamlit Integration\n\nThis project implements a **CART (Classification and Regression Tree)** Classifier in Python, designed to handle classification tasks. It provides a robust framework for training, testing, and evaluating decision trees using **gini** or **entropy** criteria. A **Streamlit** web interface is integrated to provide a user-friendly platform for interacting with the classifier.\n\n---\n\n## Features\n\n### Core Functionality\n- **Custom CART Implementation**:\n  - Supports both **Gini Index** and **Entropy** as splitting criteria.\n  - Handles dataset partitioning, threshold calculation, and weighted impurity computations.\n- **Visualization**:\n  - Displays the confusion matrix and other metrics after evaluation.\n- **Interactive Tree Traversal**:\n  - Allows users to visualize the decision tree traversal logic.\n\n### Streamlit Integration\n- **User Interface**:\n  - Upload datasets via an intuitive Streamlit web app.\n  - Configure parameters such as `max_depth`, `min_samples`, and `criterion` through sliders and dropdowns.\n- **Real-Time Evaluation**:\n  - Displays metrics like **Precision**, **Recall**, and **F1-Score** instantly after running the classifier.\n  - Visualizes the decision tree structure and confusion matrix.\n\n---\n\n## Installation\n\n### Prerequisites\n- Python 3.8 or above\n\n### Steps\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/yourusername/cart-classifier.git\n   cd cart-classifier\n   ```\n\n2. Install required libraries:\n\n   The key libraries include:\n   - `Streamlit`\n   - `numpy`\n   - `pandas`\n   - `scikit-learn`\n   - `matplotlib`\n\n---\n\n## Usage\n\n### Running the CART Classifier\n1. Modify the script `CART_Classifier.py` to load and train your dataset.\n2. Train and evaluate the classifier by calling the methods:\n   ```python\n   from CART_Classifier import CartClassifier\n   from DataHandler import DataHandler\n\n   data = DataHandler(\"path_to_dataset.csv\", label_column=\"target_column\")\n   classifier = CartClassifier(max_depth=5, min_samples=2, criterion=\"gini\")\n   classifier.fit(data)\n   precision, recall, f1 = classifier.evaluate(data, \"conf_matrix.png\")\n   print(f\"Precision: {precision}, Recall: {recall}, F1-Score: {f1}\")\n   ```\n\n### Running the Streamlit App\n1. Start the Streamlit server:\n   ```bash\n   streamlit run app/main.py\n   ```\n2. Open your browser and navigate to [http://localhost:8501](http://localhost:8501).\n3. Use the app to:\n   - Upload a dataset.\n   - Configure training parameters.\n   - Train, evaluate, and visualize the decision tree.\n\n---\n\n## Output\n\nThe Output generated is a code and an image representing the decision tree and the confusion matrix of the model\n\n**Example Code**\n\n ```python\n  import sys\n  \n  def predict(x):\n  \n      if x[5] \u003c= 9.795053004:\n          if x[1] \u003c= 9.0:\n              if x[3] \u003c= 21.0:\n                  if x[0] \u003c= 65.0:\n                      return 0\n                  else:\n                      return 0\n              else:\n                  if x[0] \u003c= 48.0:\n                      return 1\n                  else:\n                      return 0\n          else:\n              if x[3] \u003c= 13.0:\n                  return 0\n              else:\n                  if x[3] \u003c= 24.0:\n                      return 1\n                  else:\n                      return 0\n      else:\n          if x[1] \u003c= 7.0:\n              if x[4] \u003c= 18.0:\n                  if x[4] \u003c= 2.0:\n                      return 1\n                  else:\n                      return 0\n              else:\n                  if x[0] \u003c= 68.0:\n                      return 1\n                  else:\n                      return 0\n          else:\n              if x[1] \u003c= 11.0:\n                  if x[4] \u003c= 11.0:\n                      return 1\n                  else:\n                      return 1\n              else:\n                  if x[3] \u003c= 53.0:\n                      return 1\n                  else:\n                      return 0\n                  \n  \n  x = eval(sys.argv[1])\n  result = predict(x)\n  print(result)\n ```\n\n---\n\n## Key Features in the Streamlit App\n- **Dataset Upload**: Allows users to upload a CSV dataset.\n- **Model Configuration**:\n  - Adjust `max_depth`, `min_samples`, and `criterion`.\n- **Results Visualization**:\n  - View metrics (Precision, Recall, F1-Score).\n  - Display and save the confusion matrix.\n  - Visualize the decision tree traversal logic.\n\n---\n\n## Example Workflow\n1. **Upload Dataset**: Select a dataset via the Streamlit app.\n2. **Configure Parameters**: Choose training parameters (e.g., `max_depth` = 5).\n3. **Train the Model**: Run the CART classifier.\n4. **View Results**: Check metrics, visualize the tree, and download outputs.\n\n---\n\n## Future Enhancements\n- **Tree Visualization**: Implement graphical tree visualization using libraries like Graphviz.\n- **Multi-Classifier Support**: Add support for other decision tree algorithms.\n- **Model Export**: Enable saving and loading of trained models.\n\n## Contact\nFor queries or contributions, reach out at **[aswajith707@gmail.com](mailto:aswajith707@gmail.com)**.\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faswajith7077%2Fdecisiontreepredictor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faswajith7077%2Fdecisiontreepredictor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faswajith7077%2Fdecisiontreepredictor/lists"}