July 2017
Intermediate to advanced
382 pages
9h 13m
English
OpenCV's implementation of decision trees is good enough if you are just starting out, and don't care too much about what's going on under the hood. However, in the following sections, we will switch to scikit-learn. Its implementation allows us to customize the algorithm and makes it a lot easier to investigate the inner workings of the tree. Its usage is also much better documented.
In scikit-learn, decision trees can be used for both classification and regression. They reside in the tree module:
In [21]: from sklearn import tree
Similar to OpenCV, we then create an empty decision tree using the DecisionTreeClassifier constructor:
In [22]: dtc = tree.DecisionTreeClassifier()
The tree can then be trained ...
Read now
Unlock full access