Libsvm uses a custom Kernel Function

Source: Internet
Author: User

Libsvm is an open source toolkit for implementing SVM algorithm (http://www.csie.ntu.edu.tw /~ Cjlin/libsvm/), I have recently used Libsvm for a custom kernel function. Many matlab versions on the Internet use the custom Kernel Function Matrix, for example: http://www.shamoxia.com/html/y2011/3003.html. However, Java and C ++ Versions differ from matlab versions. In addition, the latest version of Libsvm is added with a multi-classification solution. Therefore, I used the Java-version custom kernel function method.

For a custom kernel function, libsvm is called Precomputed Kernels. The example is as follows:

Assume the original training data has three four-feature instances and testing data has one instance:

15

25 3:1

15

If the linear kernel is used, we have the following new training/testing sets:


45
25
 
15 0 :?

? Can be any value.

Among them, 15, 45 and so on are categories, while the second is the matrix of the User-Defined Function. The calculated value is shown in the second matrix when the linear kernel is used. The details are as follows:

Category 0: Index (the number of the data records) 1: core function value 2 of the first data record, core function value of the second data record ...... N: the value of the nth data.

After the custom kernel function constructs the matrix, the call method is svm_train-t 4 [other optional parameters] kernel_file (Kernel Function Matrix file) Model_file (model file ). In this way, we can easily apply the kernel function matrix of Java and C ++ versions.

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.