LIBSVM Experimental Correlation function

Source: Internet
Author: User

(1)Libsvmread is mainly used for reading data
The data here is non-MATLAB. MAT data, such as. Txt,.data and so on, this time need to use the Libsvmread function to convert to MATLAB identifiable data, such as the data is Heart_scale data, There are two ways to import into Matlab, one using the Libsvmread function, in MATLAB directly libsvmread (Heart_scale), the second way is to click on the "Import data" button Matlab, and then directed Heart_ Scale location, direct selection is possible. Personal feeling the second way is super good, no matter what data, such as the data you download in which database, how to turn it into MATLAB under the data? Because some data libsvmread read, but ' import data ' can become MATLAB under the data.

(2)libsvmwrite writing function is to save the known data.
Used in the following ways: Libsvmwrite (' filename ', label_vector, Instance_matrix);
Label_vector is a label, Instance_matrix is a data matrix (note that this data must be a sparse matrix, that is, the data inside does not contain useless data (such as many 0), such data should be removed and then saved.

(3) Svmtrain training function, training data to produce a model of  
is generally used directly as: Model=svmtrain (label,data,cmd); label is a tag, Data for the training data (there is a fastidious, each behavior of a sample of all the data, the number of columns represents the number of samples), each sample must correspond to a label (classification problem is generally two classification problem, that is, each sample corresponding to a label). CMD is the corresponding command set, what are the commands? Many,-v,-t,-g,-c, and so on, different parameters represent different meanings, such as for the classification problem, here-T is the choice of the kernel function type,-t=0 linear kernel. -t=1 polynomial kernel,-t=2, radial basis function (Gauss),-t=3,sigmod kernel function, a new version of the-t=4, is expected to calculate the core (not yet);-G is the parameter coefficient of the kernel function,-C is the penalty factor coefficient,-V is the number of cross-validation, the default is 5, This parameter in Svmtrain write out use and do not write out when not used, the model came out of something different, do not write when, model for a structure, is a model, can be brought into the svmpredict directly use, write out when, come out is a training model accuracy rate, As a numeric value. In general, these parameters are important, there are many other parameters, you can refer to the online comparison of the whole, because the following method of face recognition using so many parameters, the other is not written.

(3)svmpredict training function, using the trained model to predict the data type .
How to use:
[Predicted_label,accuracy,decision_values/prob_estimates]= svmpredict (Testing_label_vector,testing_instance_ Matrix,model, ' libsvm_options ')
Or:
[Predicted_label]=svmpredict (Testing_label_vector,testing_instance_matrix, model, ' libsvm_options ')
In the first way, the output is three parameters, the type of prediction, the accuracy rate, the evaluation value (non-classification problem is used), the input as the test type (this can and can not, if not, then the accuracy of the prediction accuracy is meaningless, if there is, Then it is possible to compare this value with the predicted value of that type to get an accurate rate of accuracy, but to illustrate the point is that regardless of whether the value is not, in use, you have to add, even if not, also want to add a type value, anyway, you do not care whether it is right, which is the function of the use of the specified Then the input data value, and finally the parameter value (here the parameter value only two options,-p and-B parameters), once encountered a problem, such as I in the training function set the-g parameter is 0.1, then in the forecast is not also to specify this parameter? When you specify, the program is wrong, reminding that there is no svmpredict-g parameter, because a model will appear after Svmtrain, and in svmpredict you have used this model, and this model already contains all of your training parameters, So the svmpredict does not have this parameter, then the Libsvm_options is the-p and-B parameters. For the output of the function, two ways to call the method is not the same, the first call to all the required data are called out, the second kind of call, only called the Predicted_label prediction type, here we can see, in the Simple classification prediction model, in fact, the second way better, Both simple and practical.

LIBSVM Experimental Correlation function

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.