Most of the translations in this article are from Felomeng. The original text is aspx ">Felomeng Translation: Use of libsvm2.88 Library.
The README file of version 2.88 is similar to the README file of libsvm3.0. For the README file of version 3.0, see the following:Http://sdudata.appspot.com/4001-libsvm3.0_README
Library Usage=============
These functions and structures are in the header file"Svm. h"Has a reputation. You needC/C ++Add in source file# Include "svm. h"Statement, You need to link your programSvm. cppConnection. For more information, see"Svm-train.cAndSvm-predict.c. In the fileSvm. hUsed inLIBSVM_VERSIONThe version number is defined for readers to check.
Before classifying test data, you must use training data to create an SVM model. Models can be stored as files for future use. Once the SVM model is established, it can be used to classify new data.
-Function:Struct svm_model * svm_train (const struct svm_problem * prob, const struct svm_parameter * param );
This function is constructed based on the given parameters and training data and returns an SVM model.
StructSvm_problemFormalizing the problem:
Struct svm_problem
{
Int l;
Double * y;
Struct svm_node ** x;
};
"L"Indicates the number of instances of the training data, and"Y"Is an array used to store their target values. (The type value uses integer data, and the regression value uses real numbers)"XIs an array pointer, each Pointer Points to a sparse training vector (that is,Svm_nodeArray ).
For example, if we have the following training data:
LABELATTR1ATTR2ATTR3ATTR4ATTR5
----- ----- ----- ----- ----- -----
& Nbs