To create a decision tree classifier in Python, we can use the DecisionTreeClassifier
class from the scikit-learn
library. Here's an example:
main.py697 chars26 lines
In this example, we first load the iris dataset and split it into training and testing sets. We then create a DecisionTreeClassifier
object, train it on the training data, and test it on the testing data. Finally, we calculate the accuracy of the classifier.
gistlibby LogSnag