?? readme
字號:
Libsvm is a simple, easy-to-use, and efficient software for SVMclassification and regression. It can solve C-SVM classification,nu-SVM classification, one-class-SVM, epsilon-SVM regression, andnu-SVM regression. It also provides an automatic model selectiontool for C-SVM classification. This document explains the use oflibsvm.Libsvm is available at http://www.csie.ntu.edu.tw/~cjlin/libsvmPlease read the COPYRIGHT file before using libsvm.Quick Start===========If you are new to SVM and if the data is not large, please go to tools directory and use easy.py after installation. It does everything automatic -- from data scaling to parameter selection.Usage: easy.py training_file [testing_file]More information about parameter selction can be found intools/README.Installation============On Unix systems, type `make' to build the `svm-train' and `svm-predict'programs. Run them without arguments to show the usages of them.On other systems, consult `Makefile' to build them (e.g., see'Building Windows binaries' in this file) or use the pre-builtbinaries (Windows binaries are in the directory `windows').The format of training and testing data file is:<label> <index1>:<value1> <index2>:<value2> ......<label> is the target value of the training data. For classification,it should be an integer which identifies a class (multi-classclassification is supported). For regression, it's any realnumber. For one-class SVM, it's not used so can be any number. <index>is an integer starting from 1, <value> is a real number. The indicesmust be in an ascending order. The labels in the testing data file areonly used to calculate accuracy or error. If they are unknown, justfill this column with a number.There is a sample data for classification in this package:heart_scale.Type `svm-train heart_scale', and the program will read the trainingdata and output the model file `heart_scale.model'. If you have a testset called heart_scale.t, then you type `svm-predict heart_scale.theart_scale.model output' to see the prediction accuracy on the testdata. The `output' file contains the predicted class label.There are some other useful programs in this package.svm-scale: This is a tool for scaling input data file.svm-toy: This is a simple graphical interface which shows how SVM separate data in a plane. You can click in the window to draw data points. Use "change" button to choose class 1, 2 or 3 (i.e., up to three classes are supported), "load" button to load data from a file, "save" button to save data to a file, "run" button to obtain an SVM model, and "clear" button to clear the window. You can enter options in the bottom of the window, the syntax of options is the same as `svm-train'. Note that "load" and "save" consider data in the classification but not the regression case. Each data point has one label (the color) which must be 1, 2, or 3 and two attributes (x-axis and y-axis values) in [0,1]. Type `make' in respective directories to build them. You need Qt library to build the Qt version. (You can download it from http://www.trolltech.com) You need GTK+ library to build the GTK version. (You can download it from http://www.gtk.org) We use Visual C++ to build the Windows version. The pre-built Windows binaries are in the windows directory.`svm-train' Usage=================Usage: svm-train [options] training_set_file [model_file]options:-s svm_type : set type of SVM (default 0) 0 -- C-SVC 1 -- nu-SVC 2 -- one-class SVM 3 -- epsilon-SVR 4 -- nu-SVR-t kernel_type : set type of kernel function (default 2) 0 -- linear: u'*v 1 -- polynomial: (gamma*u'*v + coef0)^degree 2 -- radial basis function: exp(-gamma*|u-v|^2) 3 -- sigmoid: tanh(gamma*u'*v + coef0)-d degree : set degree in kernel function (default 3)-g gamma : set gamma in kernel function (default 1/k)-r coef0 : set coef0 in kernel function (default 0)-c cost : set the parameter C of C-SVC, epsilon-SVR, and nu-SVR (default 1)-n nu : set the parameter nu of nu-SVC, one-class SVM, and nu-SVR (default 0.5)-p epsilon : set the epsilon in loss function of epsilon-SVR (default 0.1)-m cachesize : set cache memory size in MB (default 100)-e epsilon : set tolerance of termination criterion (default 0.001)-h shrinking: whether to use the shrinking heuristics, 0 or 1 (default 1)-b probability_estimates: whether to train an SVC or SVR model for probability estimates, 0 or 1 (default 0)-wi weight: set the parameter C of class i to weight*C in C-SVC (default 1)-v n: n-fold cross validation modeThe k in the -g option means the number of attributes in the input data.option -v randomly splits the data into n parts and calculates crossvalidation accuracy/mean squared error on them.`svm-predict' Usage===================Usage: svm-predict [options] test_file model_file output_fileoptions:-b probability_estimates: whether to predict probability estimates, 0 or 1 (default 0); one-class SVM not supported yetmodel_file is the model file generated by svm-train.test_file is the test data you want to predict.svm-predict will produce output in the output_file.Tips on practical use=====================* Scale your data. For example, scale each attribute to [0,1] or [-1,+1].* For C-SVC, consider using the model selection tool in the tools directory.* nu in nu-SVC/one-class-SVM/nu-SVR approximates the fraction of training errors and support vectors.* If data for classification are unbalanced (e.g. many positive and few negative), try different penalty parameters C by -wi (see examples below).* Specify larger cache size (i.e., larger -m) for huge problems.Examples========> svm-scale -l -1 -u 1 -s range train > train.scale> svm-scale -r range test > test.scaleScale each feature of the training data to be in [-1,1]. Scalingfactors are stored in the file range and then used for scaling thetest data.> svm-train -s 0 -c 1000 -t 2 -g 0.5 -e 0.00001 data_file Train a classifier with RBF kernel exp(-0.5|u-v|^2) and stoppingtolerance 0.00001> svm-train -s 3 -p 0.1 -t 0 -c 10 data_fileSolve SVM regression with linear kernel u'v and C=10, and epsilon = 0.1in the loss function.> svm-train -s 0 -c 10 -w1 1 -w-1 5 data_fileTrain a classifier with penalty 10 for class 1 and penalty 50for class -1.> svm-train -s 0 -c 500 -g 0.1 -v 5 data_fileDo five-fold cross validation for the classifier usingthe parameters C = 500 and gamma = 0.1> svm-train -s 0 -b 1 data_file> svm-predict -b 1 test_file data_file.model output_fileObtain a model with probability information and predict test data withprobability estimatesLibrary Usage=============These functions and structures are declared in the header file `svm.h'.You need to #include "svm.h" in your C/C++ source files and link yourprogram with `svm.cpp'. You can see `svm-train.c' and `svm-predict.c'for examples showing how to use them.Before you classify test data, you need to construct an SVM model(`svm_model') using training data. A model can also be saved ina file for later use. Once an SVM model is available, you can use itto classify new data.- Function: struct svm_model *svm_train(const struct svm_problem *prob, const struct svm_parameter *param); This function constructs and returns an SVM model according to the given training data and parameters. struct svm_problem describes the problem: struct svm_problem { int l; double *y; struct svm_node **x; }; where `l' is the number of training data, and `y' is an array containing their target values. (integers in classification, real numbers in regression) `x' is an array of pointers, each of which points to a sparse representation (array of svm_node) of one training vector. For example, if we have the following training data: LABEL ATTR1 ATTR2 ATTR3 ATTR4 ATTR5 ----- ----- ----- ----- ----- ----- 1 0 0.1 0.2 0 0 2 0 0.1 0.3 -1.2 0 1 0.4 0 0 0 0 2 0 0.1 0 1.4 0.5 3 -0.1 -0.2 0.1 1.1 0.1 then the components of svm_problem are: l = 5 y -> 1 2 1 2 3 x -> [ ] -> (2,0.1) (3,0.2) (-1,?) [ ] -> (2,0.1) (3,0.3) (4,-1.2) (-1,?) [ ] -> (1,0.4) (-1,?) [ ] -> (2,0.1) (4,1.4) (5,0.5) (-1,?) [ ] -> (1,-0.1) (2,-0.2) (3,0.1) (4,1.1) (5,0.1) (-1,?) where (index,value) is stored in the structure `svm_node': struct svm_node { int index; double value; }; index = -1 indicates the end of one vector. struct svm_parameter describes the parameters of an SVM model: struct svm_parameter { int svm_type; int kernel_type; double degree; /* for poly */ double gamma; /* for poly/rbf/sigmoid */ double coef0; /* for poly/sigmoid */ /* these are for training only */ double cache_size; /* in MB */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -