📄 readme
字号:
----------------------------------------------------- Document for MATLAB interface of LIBLINEAR -----------------------------------------------------Table of Contents=================- Introduction- Installation- Usage- Returned Model Structure- Examples- Other Utilities- Additional InformationIntroduction============This tool provides a simple interface to LIBLINEAR, a library forlarge-scale regularized linear classification(http://www.csie.ntu.edu.tw/~cjlin/liblinear). It is very easy to useas the usage and the way of specifying parameters are the same as thatof LIBLINEAR.Installation============On Unix systems, we recommend using GNU g++ as your compiler and type'make' to build 'train.mexglx' and 'predict.mexglx'. Note that weassume your MATLAB is installed in '/usr/local/matlab', if not, pleasechange MATLABDIR in Makefile.Example: linux> makeOn Windows systems, pre-built 'train.mexw32' and 'predict.mexw32' areincluded in this package (in ..\windows), so no need to conduct installation.If you have 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 7.1 in C:\Program Files\Microsoft Visual Studio [0] None Compiler: 1 Please verify your choices: Compiler: Microsoft Visual C/C++ 7.1 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 = train(training_label_vector, training_instance_matrix [,'liblinear_options', 'col']); -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 must be a sparse matrix. -liblinear_options: A string of training options in the same format as that of LIBLINEAR. -col: if 'col' is set, each column of training_instance_matrix is a data instance. Otherwise each row is a data instance.matlab> [predicted_label, accuracy, decision_values/prob_estimates] = predict(testing_label_vector, testing_instance_matrix, model [, 'liblinear_options', 'col']); -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 must be a sparse matrix. -model: The output of train. -liblinear_options: A string of testing options in the same format as that of LIBLINEAR. -col: if 'col' is set, each column of testing_instance_matrix is a data instance. Otherwise each row is a data instance.Returned Model Structure========================The 'train' function returns a model which can be used for futureprediction. It is a structure and is organized as [Parameters, nr_class,nr_feature, bias, Label, w]: -Parameters: Parameters -nr_class: number of classes -nr_feature: number of features in training data (without including the bias term) -bias: If >= 0, we assume one additional feature is added to the end of each data instance. -Label: label of each class -w: a n-by-nr_classifier matrix for the weights, where n is nr_feature or nr_feature+1 depending on the existence of the bias term. nr_classifier is the number of trained classifiers. It is 1 if nr_class=2, and is nr_class otherwise.If the '-v' option is specified, cross validation is conducted and thereturned model is just a scalar: cross-validation accuracy.Result of Prediction====================The function 'predict' has three outputs. The first one,predicted_label, is a vector of predicted labels.The second output is a scalar meaning accuracy.The third is a matrix containing decision values or probabilityestimates (if '-b 1' is specified). If k is the number of classesand k' is the number of classifiers (k'=1 if k=2, otherwise k'=k), for decision values,each row includes results of k' binary linear classifiers. 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> [heart_scale_label, heart_scale_inst] = read_sparse('../heart_scale');matlab> model = train(heart_scale_label, heart_scale_inst, '-c 1');matlab> [predict_label, accuracy, dec_values] = predict(heart_scale_label, heart_scale_inst, model); % test the training dataNote that for testing, you can put anything in the testing_label_vector.For probability estimates, you need '-b 1' for training and testing:matlab> [predict_label, accuracy, prob_estimates] = predict(heart_scale_label, heart_scale_inst, model, '-b 1');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 train or predict. This code is derived from svm-train.c inLIBSVM by Rong-En Fan from National Taiwan University.Additional Information======================Please cite LIBLINEAR as followsC.-J. Lin, R. C. Weng, and S. S. Keerthi.Trust region Newton method for large-scale regularized logisticregression. Technical report, 2007. A short version appearsin ICML 2007. Software available at http://www.csie.ntu.edu.tw/~cjlin/liblinearFor any question, please contact Chih-Jen Lin <cjlin@csie.ntu.edu.tw>.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -