Java program uses WEKA to call libsvm

Source: Internet
Author: User

 

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.