Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geekquad/decision-tree-from-scratch
A basic project to implement and visualize Decision Tree Classifier from Scratch.
https://github.com/geekquad/decision-tree-from-scratch
decision-tree-classifier graphviz pydotplus sklearn supervised-learning
Last synced: 14 days ago
JSON representation
A basic project to implement and visualize Decision Tree Classifier from Scratch.
- Host: GitHub
- URL: https://github.com/geekquad/decision-tree-from-scratch
- Owner: geekquad
- Created: 2020-06-18T20:29:06.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-21T17:51:56.000Z (over 4 years ago)
- Last Synced: 2024-11-10T08:43:41.214Z (2 months ago)
- Topics: decision-tree-classifier, graphviz, pydotplus, sklearn, supervised-learning
- Language: Jupyter Notebook
- Homepage:
- Size: 4.76 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Decision-Tree-from-Scratch
A decision tree is a flowchart-like tree structure where an internal node represents feature(or attribute), the branch represents a decision rule, and each leaf node represents the outcome. This flowchart-like structure helps us in decision making.
This is why decision trees are easy to understand and interpret.
Parameters:
- min_samples_split (default value = 2)
- criterion : optional (default=”gini”)
- splitter
nodes cannot be further seperated below this value.
It controls how a Decision Tree decides where to split the data.
It is the measure of impurity in a bunch of examples.
This parameter allows us to use the different-different attribute selection measure. Supported criteria are “gini” for the Gini index and “entropy” for the information gain.
This parameter allows us to choose the split strategy. Supported strategies are “best” to choose the best split and “random” to choose the best random split.
Documentation of Decision Tree:
https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html
For Visualization
Import the following libraries:
```
from sklearn.tree import export_graphviz
from sklearn.externals.six import StringIO
from IPython.display import Image
import pydotplus
```
If the error **Graphviz executables not found** occurs, then run the following command:
```
import os
os.environ['PATH'] = os.environ['PATH']+';'+os.environ['CONDA_PREFIX']+r"\Library\bin\graphviz"
```
Visualization and Accuracy of the Tree using default parameters:
Accuracy : 0.66
Visualization and Accuracy of the Tree after parameter tuning:
Accuracy : 0.77
This pruned model is less complex, explainable, and easy to understand than the previous decision tree model plot.