> I want to read the J48 model intto if-else structure using toSource
> method. Can you check if there is any problem with my code? it prints
> out the tree several times besides the if-else code.
> J48 cls2 = (J48) weka.core.SerializationHelper.read("test_data/j48.model");
> String x =cls2.toString();
> String x2 =cls2.toSource(x);
> System.out.print(x2);
If you read the Javadoc, it should be fairly clear what's wrong. The
"toString()" method of a classifier returns a string representation of
its model (if the classifier generates one). The "toSource(String)"
method expects a classname as parameter. Using the string
representation of the tree as classname doesn't seem such a good idea
(it won't generate valid Java code either).
Cheers, Peter
--
Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ
http://www.cs.waikato.ac.nz/~fracpete/ Ph. +64 (7) 858-5174
_______________________________________________
Wekalist mailing list
Send posts to:
Wekalist@...
List info and subscription status:
https://list.scms.waikato.ac.nz/mailman/listinfo/wekalistList etiquette:
http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html