⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 基于支持向量机的分类识别程序
💻
字号:
-------------------------------------------------- Document for MATLAB interface of LIBSVM --------------------------------------------------Table of Contents=================- Introduction- Installation- Usage- Returned Model Structure- Examples- Other Utilities- Additional InformationIntroduction============This tool provides a simple interface to LIBSVM, a library for support vectormachines (http://www.csie.ntu.edu.tw/~cjlin/libsvm). It is very easy to use asthe usage and the way of specifying parameters are the same as that of LIBSVM.Installation============On Unix systems, we recommend using GNU g++ (version < 3.4) as yourcompiler and type 'make' to build 'svmtrain.mexglx' and 'svmpredict.mexglx'.Note that we assume your MATLAB is installed in '/usr/local/matlab',if not, please change MATLABDIR in Makefile.Example:        linux> makeOn Windows systems, pre-built 'svmtrain.dll' and 'svmpredict.dll' areincluded in this package, so no need to conduct installation. If youhave modified the sources and would like to re-build the package, type'mex -setup' in MATLAB to choose a compiler for mex first. Then type'make' to start the installation.Example:        matlab> mex -setup        (ps: MATLAB will show the following messages to setup default compiler.)        Please choose your compiler for building external interface (MEX) files:         Would you like mex to locate installed compilers [y]/n? y        Select a compiler:         [1] Microsoft Visual C/C++ version 6.0 in C:\Program Files\Microsoft Visual Studio         [0] None         Compiler: 1        Please verify your choices:         Compiler: Microsoft Visual C/C++ 6.0         Location: C:\Program Files\Microsoft Visual Studio         Are these correct?([y]/n): y        matlab> makeFor list of supported/compatible compilers for MATLAB, please check thefollowing page:http://www.mathworks.com/support/tech-notes/1600/1601.htmlUsage=====matlab> model = svmtrain(training_label_vector, training_instance_matrix, [,'libsvm_options']);        -training_label_vector:            An m by 1 vector of training labels.        -training_instance_matrix:            An m by n matrix of m training instances with n features.            It can be dense or sparse.        -libsvm_options:            A string of training options in the same format as that of LIBSVM.matlab> [predicted_label, accuracy, decision_values/prob_estimates] = svmpredict(testing_label_vector, testing_instance_matrix, model [,'libsvm_options']);        -testing_label_vector:            An m by 1 vector of prediction labels. If labels of test            data are unknown, simply use any random values.        -testing_instance_matrix:            An m by n matrix of m testing instances with n features.            It can be dense or sparse.        -model:            The output of svmtrain.        -libsvm_options:            A string of testing options in the same format as that of LIBSVM.Returned Model Structure========================The 'svmtrain' function returns a model which can be used for futureprediction.  It is a structure and is organized as [Parameters, nr_class,totalSV, rho, Label, ProbA, ProbB, nSV, sv_coef, SVs]:        -Parameters: parameters        -nr_class: number of classes; = 2 for regression/one-class svm        -totalSV: total #SV        -rho: -b of the decision function(s) wx+b        -Label: label of each class; empty for regression/one-class SVM        -ProbA: pairwise probability information; empty if -b 0 or in one-class SVM        -ProbB: pairwise probability information; empty if -b 0 or in one-class SVM        -nSV: number of SVs for each class; empty for regression/one-class SVM        -sv_coef: coefficients for SVs in decision functions        -SVs: support vectorsIf you do not use the option '-b 1', ProbA and ProbB are emptymatrices. If the '-v' option is specified, cross validation isconducted and the returned model is just a scalar: cross-validationaccuracy for classification and mean-squared error for regression.More details about this model can be found in LIBSVM FAQ(http://www.csie.ntu.edu.tw/~cjlin/libsvm/faq.html) and LIBSVMimplementation document(http://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.pdf).Result of Prediction====================The function 'svmpredict' has three outputs. The first one,predictd_label, is a vector of predicted labels. The second output,accuracy, is a vector including accuracy (for classification), meansquared error, and squared correlation coefficient (for regression).The third is a matrix containing decision values or probabilityestimates (if '-b 1' is specified). If k is the number of classes, for decision values, each row includes results of predicting k(k-1/2) binary-class SVMs. For probabilities, each row contains k values indicating the probability that the testing instance is ineach class. Note that the order of classes here is the same as 'Label'field in the model structure.Examples========Train and test on the provided data heart_scale:matlab> load heart_scale.matmatlab> model = svmtrain(heart_scale_label, heart_scale_inst, '-c 1 -g 2');matlab> [predict_label, accuracy, dec_values] = svmpredict(heart_scale_label, heart_scale_inst, model); % test the training dataFor probability estimates, you need '-b 1' for training and testing:matlab> load heart_scale.matmatlab> model = svmtrain(heart_scale_label, heart_scale_inst, '-c 1 -g 2 -b 1');matlab> load heart_scale.matmatlab> [predict_label, accuracy, prob_estimates] = svmpredict(heart_scale_label, heart_scale_inst, model, '-b 1');To use precomputed kernel, you must include sample serial number asthe first column of the training and testing data (assume your kernelmatrix is K, # of instances is n):matlab> K1 = [(1:n)', K]; % include sample serial number as first columnmatlab> model = svmtrain(label_vector, K1, '-t 4');matlab> [predict_label, accuracy, dec_values] = svmpredict(label_vector, K1, model); % test the training dataTake linear kernel for example, the following precomputed kernel example gives exactly same training error as LIBSVM built-in linear kernelmatlab> load heart_scale.matmatlab> n = size(heart_scale_inst,1);matlab> K = heart_scale_inst*heart_scale_inst';matlab> K1 = [(1:n)', K];matlab> model = svmtrain(heart_scale_label, K1, '-t 4');matlab> [predict_label, accuracy, dec_values] = svmpredict(heart_scale_label, K1, model);       Note that for testing, you can put anything in the first column.  Fordetails of precomputed kernels, please read the section ``PrecomputedKernels'' in the README of the LIBSVM package.Other Utilities===============A matlab function read_sparse reads files in LIBSVM format: [label_vector, instance_matrix] = read_sparse(fname); Two outputs are labels and instances, which can then be used as inputsof svmtrain or svmpredict. This code is derived from svm-train.c inLIBSVM by Rong-En Fan from National Taiwan University.Additional Information======================This interface was initially written by Jun-Cheng Chen, Kuan-Jen Peng,Chih-Yuan Yang and Chih-Huai Cheng from Department of ComputerScience, National Taiwan University. The current version was preparedby Rong-En Fan and Ting-Fan Wu. If you find this tool useful, pleasecite LIBSVM as followsChih-Chung Chang and Chih-Jen Lin, LIBSVM : a library forsupport vector machines, 2001. Software available athttp://www.csie.ntu.edu.tw/~cjlin/libsvmFor any question, please contact Chih-Jen Lin <cjlin@csie.ntu.edu.tw>.Or check the FAQ page:http://www.csie.ntu.edu.tw/~cjlin/libsvm/faq.html#/Q9:_MATLAB_interface

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -