# Decision tree Algorithm

Decision tree algorithm is a commonly used supervised learning algorithm, solves classification problems. Decision tree is the graphical representation of all the possible solutions to a decision. Decisions are based on some conditions.

Decision tree is a tree-like structure, that breaks down a dataset into smaller and smaller subsets. The final result is a tree with decision nodes and leaf nodes. The topmost decision node in a tree which corresponds to the best predictor called the root node.

The entire tree implements by answering “True/False” questions until it reaches the leaf node. Decision tree can handle both categorical and numerical data. They are extremely useful for data analytics and machine learning because they break down complex data into more manageable parts. They’re often used in these fields for prediction analysis, data classification, and regression.

##### Example of Decision tree Algorithm:

In the above example the root node checks whether the person is hungry. If the person is not hungry, then it goes to eat after sometime, else checks whether it is lunch time. If it is lunch time the person gets the food, else he will get after some time. The final eat node is the decision node.

Another example of Decision tree:

### Implementation of Decision tree algorithm:

1. Import the required libraries.
2.  Initialize and print the dataset.
3. Fit decision tree to the dataset.
4. Predicting the result with new value.
5. Visualizing the result.