How to extract the underlying decision-rules (or 'decision paths') from a trained tree in a decision tree as a textual list?
if A>0.4 then if B0.8 then class='X' In order to extract the decision rules, we can use the following code. from sklearn.tree import _tree def tree_to_code(tree, feature_names): tree_ = tree.tree_ feature_name = [ feature_names[i] if i != _tree.TREE_UNDEFINED else "undefined!"
Answered Nov 4, 2019 · 1.5K Views Read answer →