From: Aaron A. <aa...@cb...> - 2010-04-23 18:06:07
|
Hi Julien, First, thanks for the detailed error message. While I'm no longer a main developer (and so I won't edit the public repository), it looks like the problem is a simple typo. In AlternatingTree.java, there should be code that looks like this (line numbers may not match up): 1051 private String makePythonCode(SplitterNode sn, String tab) { 1052 String code = ""; 1053 1054 Summary summary=sn.splitter.getSummary(); 1055 1056 code += tab + (allDefined 1057 ? " " 1058 : "if def(" + (summary.index+1) + "):") 1059 + " # " + sn.id + "\n"; 1060 String stab = (allDefined ? tab : tab); 1061 switch(summary.type) { 1062 case Summary.EQUALITY: 1063 code += stab + "if self.get_data_value(x,'" + ad[(summary.index)].getAttributeName() + "') == " + 1064 ((Integer)summary.val) + ":\n"; 1065 code += makeMatlabCode(sn.predictorNodes[0], stab + "\t"); 1066 code += stab + "else:\n"; 1067 code += makeMatlabCode(sn.predictorNodes[1], stab + "\t"); 1068 break; 1069 case Summary.LESS_THAN: 1070 code += stab + "if self.get_data_value(x,'" + ad[(summary.index)].getAttributeName() + "') <= " + 1071 ((Double) summary.val) + ":\n"; 1072 code += makePythonCode(sn.predictorNodes[0], stab + "\t"); 1073 code += stab + "else:\n"; 1074 code += makePythonCode(sn.predictorNodes[1], stab + "\t"); 1075 break; 1076 default: 1077 throw new RuntimeException("Type of split not allowed"); 1078 } 1079 1080 return code; 1081 } Notice the three lines: 1065 code += makeMatlabCode(sn.predictorNodes[0], stab + "\t"); 1066 code += stab + "else:\n"; 1067 code += makeMatlabCode(sn.predictorNodes[1], stab + "\t"); These calls should be changed to recursively call the Python method whereas they are currently calling the matlab method: 1065 code += makePythonCode(sn.predictorNodes[0], stab + "\t"); 1066 code += stab + "else:\n"; 1067 code += makePythonCode(sn.predictorNodes[1], stab + "\t"); You may also have to change the line 1064 ((Integer)summary.val) + ":\n"; So that it can handle strings (though the strings may be converted to integers, and this may be easier to edit once the python code has been outputted using a dictionary, etc). I don't remember the exact internal string representation, but you can email again if you have further problems. Running 'ant jar' or 'ant dist' in the top directory will compile the code (make sure the file 'JBOOST_DIR/dist/jboost.jar' has been updated). Aaron On Fri, 23 Apr 2010, Julien Hénot wrote: > Hi all, > > I am a new user of JBoost and I'm very enthusiastic and happy to use it. > It's really simple to start and I succeed easily in having some good > results. > > I would ask you a little question. > > When I run my Jboost command with generation of python code, I have this > exception : > > Exception occured while attempting to write Python code > Message:java.lang.RuntimeException: Type of split not allowed > java.lang.RuntimeException: Type of split not allowed > at jboost.atree.AlternatingTree.makeMatlabCode(AlternatingTree.java:780) > at jboost.atree.AlternatingTree.makeMatlabCode(AlternatingTree.java:751) > at jboost.atree.AlternatingTree.makeMatlabCode(AlternatingTree.java:765) > at jboost.atree.AlternatingTree.makeMatlabCode(AlternatingTree.java:751) > at jboost.atree.AlternatingTree.makeMatlabCode(AlternatingTree.java:775) > at jboost.atree.AlternatingTree.makeMatlabCode(AlternatingTree.java:751) > at jboost.atree.AlternatingTree.makePythonCode(AlternatingTree.java:705) > at jboost.atree.AlternatingTree.makePythonCode(AlternatingTree.java:691) > at jboost.atree.AlternatingTree.toPython(AlternatingTree.java:654) > at jboost.controller.Controller.generateCode(Controller.java:694) > at > jboost.controller.Controller.outputLearningResults(Controller.java:273) > at jboost.controller.Controller.main(Controller.java:91) > > > Have you an idea ? I look the code but I did not succeed to fix the problem. > > I have different types of value in my spec file : number, text, and finite > (none,same,not) > > Thanks in advance, > > Regards, > Julien Henot > |