Decision tree: how to save rules of each leaf?

Hi, instead of saving decision tree as picture, does anyone know how to save rules of each leaf in text or other format? I have also saved the decision tree into .pmml, but it is not good looking for further development. So, I think it should be helpful if I can save the decision tree leaf by leaf (rule by rule). Any good idea? Thanks.

Our decision trees are saved as PMML. PMML is a Model language which uses XML.

Hence using XML queries it is for sure possible to export all of the rules.
The PMML to Cell node creates a PMML Cell (which is a XML Cell) from the PMML port.
This cell can be processed with the XML nodes.

Hope this helps, Iris

Thanks for your reply, Iris.

I have follow Iris's suggesstion to convert PMML to XML. However, it is still hard to identify the path to each leaf. In some application, if I need to change node score from 'true' to 'false'manually, it is almost impossible, especially for a big decision tree which has thousand nodes. Anyone has good idea? Thanks.

I don't think there's any easy way to parse the trees. A xqueryxpath query or a parser may need to be used.

To obtain rules that are interpretable and simple the part and nnge nodes in weka are quite useful. The output is in the form of if then rules like so.

 

A. PART Node

val2 <= 5.316789 AND
NumSaturatedRings <= 0 AND
peoe_VSA2 <= 9.507073: Bin1 (60.0)

NumRotatableBonds <= 0: Bin3 (4.0/1.0)

slogp_VSA1 <= 5.733667 AND
peoe_VSA3 <= 0 AND
NumHBA <= 1: Bin1 (4.0)

TPSA1 <= 29.1 AND
peoe_VSA8 <= 6.606882: Bin1 (5.0)

B. NNGe node

Bin1 IF : 0.36430000000000007<=SlogP<=1.0956199999999998 ^ 25.03799999999999<=SMR<=36.176500000000004

Bin2 IF : SlogP=1.8667 ^ SMR=35.894000000000005 ^ LabuteASA=54.55386702975889 ^ TPSA=23.79

 

While modifying the original model may still be hard you can at least quickly obtain the rule branches.

 

 

 

Hi,

I know this thread is a bit outdated.  However, I wanted to share that I was able to parse the PMML output from a Decision Tree into a .csv file using several XPath nodes and Java Snippets.  I had to also use Variable to Table Row Loops, Row to Variable, several Concatenations, Joiners, and Column Appenders.

I have attached my .csv output from the KNIME Example Workflow in addition to the new layout of that example from KNIME showing where my modification took place.

I am in the process of finding the best way to share this with those interested.

Thanks!

Hi farismismar,

thank you for your kind offer and sorry for the late reply. We are very interested in your meta node and would like to upload it to our Example Server to make it public available for everyone, if this is fine with you.

Therefore we need to check the meta node. Could you please send me the meta node via Email. I will send you a personal message with my email address. It is important to the meta node contains an annotation with your authoring information included.

I am very interested in the node and keen to have a look at it.

Cheers, Kilian

Hi Kilian,

I sent you a copy of it via e-mail.  Looking forward to your response back in e-mail.

Dear Kilian, Dear Farismismar,

Many thanks Farismismar for sharing your metanode and many thanks Kilian for making it available to everybody at the Server Example. I would be interested too in using it. Could you please let us know when and under what name the metanode and workflow become available at the Example Server ? Many thanks in advance.

Best regards,

Christophe

Hi Kilian,

Any good news that you can share with the community regarding my metanode?  Thanks.

Dear farismismar,

I am very interested in using your metanode. Many thanks for sharing it. I would like to know if the workflow is available at the Example server. In other case, would you mind to send it to me via email? Thanks in advance.

Regards,

Irene

After being inspired by farismismar I also was able to parse out the rules from a PMML decision tree. I've attached the workflow and an example PMML decision tree that was built from a small example dataset from the UCI Machine Learning repository. 

Hope this helps. 

Hello,

This is my first day in KNIME.  I wanted to train a model and write out PMML rules for use running in another system.

Q) Can someone name an algorithm in KNIME that results in rules, and is compatible with the PMML writer node?  I have used Quinlan's C50 in the past, to train trees, but prune to rules.  http://www.rulequest.com/see5-info.html

http://rulebasedmodels.r-forge.r-project.org/Rule-Based_Models/Rule-Based_Models.html

https://cran.r-project.org/web/packages/C50/C50.pdf

 

I can train the Decision Tree Learner, and use the PMML Writer, validating basic stuff is working.

I tried training a Fuzzy Rule Learner and NNge - but neither could be connected to the PMML writer.

 

I see earlier in this thread discussion of parsing a tree into human readable rules.  I am interested in something similar, only to result in PMML rules.

Little bit outdated but, any news regardin this issue ? Currently I'm working with Fuzzy Rule Learner & Predictors, so I need to save my trained models in order to do further predictions with new data. I can't find a way to save it, say, in a PMML fashion.

 

Thanks,

Emiliano A.