MATLAB多分类,使用libsvm和linear的详解和区别

时间:2021-03-10 06:44:11

MATLAB多分类,使用libsvm和linear的区别

最近还是在做多分类的问题,之前使用的是libsvm进行多分类,主要使用的是1V1和1Vrsst,具体可参见这篇博文。这两天看到liblinear这个库,针对多分类问题有很好的改进。这里随笔记下:

liblinear链接,liblinear相比于libsvm最大的优点是快,二者针对多分类的区别在官网也有详细的解释:
For some multi-class data, the difference may be significant. The reason is that LIBSVM uses the 1-vs-1 strategy, while LIBLINEAR uses 1-vs-the rest.

意思就是LIBSVM 实现多分类的策略是1v1,而LIBLINEAR 用的是1-vs-the rest,
另外在此再解释一下LIBLINEAR 的调用:
1·数据结构和LIBSVM 保持一致,
2·但是调用参数有些变化
Usage: train [options] training_set_file [model_file]
options:
-s type : set type of solver (default 1)
for multi-class classification
0 – L2-regularized logistic regression (primal)
1 – L2-regularized L2-loss support vector classification (dual)
2 – L2-regularized L2-loss support vector classification (primal)
3 – L2-regularized L1-loss support vector classification (dual)
4 – support vector classification by Crammer and Singer
5 – L1-regularized L2-loss support vector classification
6 – L1-regularized logistic regression
7 – L2-regularized logistic regression (dual)
for regression
11 – L2-regularized L2-loss support vector regression (primal)
12 – L2-regularized L2-loss support vector regression (dual)
13 – L2-regularized L1-loss support vector regression (dual)

这里指出,liblinear的-s 参数能够制定不同的多分类策略,这里的4类型使用的 Crammer and Singer是一种较好的多分类方法,在参考文献:K. Crammer and Y. Singer, “On the learnability and design of output
codes for multiclass problems,” Comput. Learing Theory, pp. 35–46,
2000.这篇文章中提出。