nok / sklearn-porter

Transpile trained scikit-learn estimators to C, Java, JavaScript and others.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Multi-label DecisionTreeClassifier

gustavoresque opened this issue · comments

I have trained a multi-label DecisionTreeClassifier and when I ported the result is the following:

public static int predict(double[] features) {
        int[] classes = new int[2];
            
        if (features[11] <= 12.5) {
            if (features[10] <= 182.5) {
                if (features[12] <= 72.5) {
                    if (features[13] <= 63.0) {
                        if (features[7] <= 767.5) {
                            classes[0] = 20; 
                            classes[1] = 5;
                            // Here the result shoud be: 
                            //classes[0][0] = 20; classes[0][1] = 5; classes[1][0] = 25; classes[1][1] = 0; And so on...
                        }else{
                            //Huge amount of ifs
                        }
                       }
                  }
                }
             }

The full decision tree is here: tree2

I really appreciate this feature in your porter. =]

Additionally, if this feature is already present in the code, I haven't figured out how to use it.

Thank you.