which is best svm example which classifies plain input text?

pun*_*azy 5 classification machine-learning svm scikit-learn

I have checked various svm classification tools, mainly svmlight, pysvmlight, libsvm, scikit learn svm classifier.

Each take input test file in some different format like

pysvmlight:

[(0, [(13.0, 1.0), (14.0, 1.0), (173.0, 1.0), (174.0, 1.0)]),
 (0,
  [(9.0, 1.0),
   (10.0, 1.0),
   (11.0, 1.0),
   (12.0, 1.0),
   (16.0, 1.0),
   (19.0, 1.0),
   (20.0, 1.0),
   (21.0, 1.0),
   (22.0, 1.0),
   (56.0, 1.0)]
Run Code Online (Sandbox Code Playgroud)

svmlight

+1 6:0.0342598670723747 26:0.148286149621374 27:0.0570037235976456 31:0.0373086482671729 33:0.0270832794680822 63:0.0317368459004657 67:0.138424991237843 75:0.0297571881179897 96:0.0303237495966756 142:0.0241139382095992 144:0.0581948804675796 185:0.0285004985793364 199:0.0228776475252599 208:0.0366675566391316 274:0.0528930062061687 308:0.0361623318128513 337:0.0374174808347037 351:0.0347329937800643 387:0.0690970538458777 408:0.0288195477724883 423:0.0741629177979597 480:0.0719961218888683 565:0.0520577748209694 580:0.0442849093862884 593:0.329982711875242 598:0.0517245325094578 613:0.0452655621746453 641:0.0387269206869957 643:0.0398205809532254 644:0.0466353065571088 657:0.0508331832990127 717:0.0495981406619795 727:0.104798994968809 764:0.0452655621746453 827:0.0418050310923008 1027:0.05114477444793 1281:0.0633241153685135 1340:0.0657101916402099 1395:0.0522617631894159 1433:0.0471872599750513 1502:0.840963375098259 1506:0.0686138465829187 1558:0.0589627036028818 1598:0.0512079697459134 1726:0.0660884976719923 1836:0.0521934221969394 1943:0.0587388821544177 2433:0.0666767220421155 2646:0.0729483627336339 2731:0.071437898589286 2771:0.0706069752753547 3553:0.0783933439550538 3589:0.0774668403369963
Run Code Online (Sandbox Code Playgroud)

http://svm.chibi.ubc.ca//sample.test.matrix.txt

corner  feature_1   feature_2   feature_3   feature_4
example_11  -0.18   0.14    -0.06   0.54
example_12  0.16    -0.25   0.26    0.33
example_13  0.06    0.0 -0.2    -0.22
example_14  -0.12   -0.22   0.29    -0.01
example_15  -0.20   -0.23   -0.1    -0.71
Run Code Online (Sandbox Code Playgroud)

IS there any svm classifier which takes plain input text and give classification result for it?

CAF*_*ABE 5

我的回答是双重的

SVM实现直接在文本数据上工作,例如https://github.com/timshenkao/StringKernelSVM.LIBSVM也适用于http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/#libsvm_for_string_data.在文本数据上直接使用SVM的关键是所谓的String Kernel.在SVM中使用内核来测量不同数据点之间的距离,这些数据点是文本文档.String内核的一个示例是编辑不同文本文档之间的距离,参见http://www.jmlr.org/papers/volume2/lodhi02a/lodhi02a.pdf

问题是这是否是使用文本内核进行文本分类的好主意.

简化支持向量机是一个功能

f(x) = sgn( <w,phi(x)> +b)
Run Code Online (Sandbox Code Playgroud)

通常会发生的是,您获取输入文档,为这些文档计算单词表示,然后采用线性标准内核.所以类似于:

f(x) = sgn( <w,phi(bag-of-words(x))> +b)
Run Code Online (Sandbox Code Playgroud)

你最想要的是一个带有内核的SVM,它结合了一些单词和线性内核.这实现明智,但有缺点

  1. 与文本文档相比,词袋非常紧凑
  2. 您无法对文本文档进行标准化,但您可以在单词包上进行功能标准化
  3. 不分离这些步骤会使您的代码难以重用

两部分的底线:它与SVM无关,而是关于内核.