Based on "using Java to call WEKA in Eclipse", use the methods described in "using Java to call WEKA in Eclipse" to add two libsvm jar packages (libsvm. jar and wlsvm. jar) and WEKA jar packages, which can be downloaded from here: http://download.csdn.net/source/1749854.
Then, add the following statements under the import statements:
ImportWlsvm. wlsvm;
Then
Classifier m_classifier =NewJ48 ();
Changed:
Classifier m_classifier =NewWlsvm ();
Then we use SVM to classify the output sentence.
System.Out. Println ("j48 classification precision:" + (right/SUM ));
Changed:
System.Out. Println ("");
System.Out. Println ("SVM classification precision:" + (right/SUM ));
One problem with libsvm is that the memory usage is large and the following error is often prompted:
Java. Lang. outofmemoryerror: Java heap Space
It cannot be solved when the memory is insufficient, but if the memory is sufficient, you can configure the memory size parameter that the program can occupy. Setting method:
1. Select the class that calls libsvm in package explorer;
2. Click RUN> RUN configuration... -> Enter-xmx1024m In the VM arguments text box on the (x =) Arguments page on the right. // Indicates that the maximum memory usage is mb. You can set it based on the actual situation.