{"id":20937663,"url":"https://github.com/dnlbb/tree-recognition","last_synced_at":"2026-04-20T20:03:38.706Z","repository":{"id":236858614,"uuid":"793294522","full_name":"Dnlbb/Tree-recognition","owner":"Dnlbb","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-29T00:12:02.000Z","size":297,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-19T20:22:59.509Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","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/Dnlbb.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":"2024-04-28T23:52:38.000Z","updated_at":"2024-10-02T12:54:40.000Z","dependencies_parsed_at":"2024-05-03T00:09:20.841Z","dependency_job_id":null,"html_url":"https://github.com/Dnlbb/Tree-recognition","commit_stats":null,"previous_names":["dnlbb/tree-recognition"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dnlbb%2FTree-recognition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dnlbb%2FTree-recognition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dnlbb%2FTree-recognition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dnlbb%2FTree-recognition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dnlbb","download_url":"https://codeload.github.com/Dnlbb/Tree-recognition/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243330323,"owners_count":20274039,"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":[],"created_at":"2024-11-18T22:38:53.827Z","updated_at":"2025-12-25T20:57:33.440Z","avatar_url":"https://github.com/Dnlbb.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Forest Type Classification\n## Overview\nThis project focuses on the classification of forest types based on various environmental and tree features. The dataset used comprises multiple features that describe different aspects of forests, and the goal is to accurately classify each forest type. The Python script leverages machine learning techniques, specifically the K-Nearest Neighbors (KNN) algorithm, to predict forest types.\n## Dataset\nThe dataset, forest_dataset.csv, includes various features about trees and environmental conditions. The last column in the dataset represents the class labels for forest types.\n## Features\n- The dataset consists of 54 features including soil type, shade, elevation, and other environmental characteristics relevant to forestry.\n- The last column is the target variable representing different types of forests encoded as integers.\n## Requirements\n- Python 3.x\n- Libraries: pandas, numpy, sklearn, matplotlib\n## Installation\nTo set up the environment for running this project, you need to install the required libraries. You can install these using pip:\n```bash\npip install pandas numpy scikit-learn matplotlib\n```\n## Usage\n1. Load the dataset into a pandas DataFrame.\n2. Split the dataset into training and testing sets.\n3. Train a K-Nearest Neighbors (KNN) classifier on the training data.\n4. Evaluate the model on the test set.\n5. Use GridSearchCV to find the optimal parameters for the KNN classifier.\n6. Compare the classification accuracy before and after parameter tuning.\n7. Visualize the real vs predicted frequency of each class.\nAdditionally, you can use the predict_tree function to predict the forest type based on a provided feature array.\n## Predicting Forest Type\no predict the type of forest using an array of features:\n```python\n# Replace the list with your actual feature values\nfeatures = [0.1, 0.2, ..., 0.54]  # Example feature values\npredicted_class = predict_tree(features)\nprint(\"Predicted tree class:\", predicted_class)\n```\n## Example Output\nThe script will output the initial classification accuracy and the accuracy after performing grid search optimization. Additionally, a bar chart showing the real vs predicted frequency of each forest class is displayed.\n## Classes Dictionary\nThe classes are mapped as follows:\n- 0: Pine tree\n- 1: Fir\n- 2: Birch tree\n- 3: Poplar\n- 4: Oak\n- 5: Maple\nThese mappings are used to decode the predicted classes into understandable labels.\n## Visualization\nA bar chart is plotted to compare the real frequency of forest types in the test set against the predicted frequency derived from the model probabilities.\n## Conclusion\nThis project demonstrates the application of KNN for classifying forest types and the use of grid search to optimize model parameters for better accuracy. It includes a function for making predictions on new data, making it applicable for real-world forestry management and research scenarios.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnlbb%2Ftree-recognition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdnlbb%2Ftree-recognition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdnlbb%2Ftree-recognition/lists"}