It is common for decision trees with asymmetrical shapes to have leave nodes that come early. For example, the model can already generate a prediction if the answer to the first question is FALSE, without the need to ask the second question:

enter image description here

From a user experience perspective, it is advantageous to shorten the journey to get a prediction. One solution is to perform sklearn.tree.export_graphiz on the trained model, and manually script the delivery of input fields in the order the tree needs them. If a leave node is reached, the predict function is called with the inputs collected, while assigning the rest of the inputs to default values. However, this is not scaleable for large decision trees. Is there a way to order the input fields autonomously?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.