ãLIBLINEARãcross validationã«ä½¿ãè©ä¾¡å°ºåº¦ãå¤æ´ããæ¹æ³
LIBLINEAR㧠cross validation (ã¯ãã¹ããªãã¼ã·ã§ã³, 交差æ¤å®) ãè¡ãæã¯ï¼è©ä¾¡ææ¨ã¨ã㦠Accuracy ãç¨ãããã¾ãï¼ãããï¼ç¨éã«ãã£ã¦ã¯F
å¤ãªã©ï¼ä»ã®ææ¨ã使ãããæããããã¨æãã¾ãï¼
ã¨ããããã§ï¼æ¬è¨äºã§ã¯ LIBLINEAR ã® cross validation ã«ä½¿ãè©ä¾¡å°ºåº¦ãå¤æ´ããæ¹æ³ãç´¹ä»ãã¾ãï¼
å®ã¯å ¬å¼ãµã¤ãã«æ¸ãã¦ããï¼ï¼
å
¬å¼ãµã¤ãã®ä»¥ä¸ã®ãã¼ã¸ã«ï¼è©ä¾¡å°ºåº¦ãå¤æ´ããæ¹æ³ãæ¸ããã¦ãããã§ãï¼
ã¨è¨ã£ã¦ãè±èªãªã®ã§ï¼ä»¥ä¸ã«æ¥æ¬èªã§æé ã示ãã¦ããã¾ãï¼
è©ä¾¡å°ºåº¦ã®å¤æ´æ¹æ³
LIBLINEAR ãã¤ã³ã¹ãã¼ã«ãããã£ã¬ã¯ã㪠(æãã liblinear-2.01/
ã¨ãã ã¨æãã¾ã) ä¸ã§å®è¡ãã¦ä¸ããï¼
å¿ è¦ãªãã¡ã¤ã«ã®DL
å¿ è¦ãªãã¡ã¤ã« (3ã¤) ããã¦ã³ãã¼ããã¾ãï¼
$ wget http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/eval/liblinear/eval.cpp $ wget http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/eval/liblinear/eval.h $ wget -N https://gist.githubusercontent.com/shun91/ed604455722cd170e727/raw/f9656df951ae728213667724b3a2f8f1bb38e7a2/Makefile
Makefile ã¯å
ã®ãã¼ã¸ããDLãã¦ã ver.2.01 ã«å¯¾å¿ãã¦ãã¾ããï¼
ä¿®æ£ãããã®ãGistã«ããã¦ããã®ã§ï¼ãããDLãã¾ãï¼
train.c ã®ä¿®æ£
ãtrain.cãã®å é ã«ä»¥ä¸ã®1è¡ã追è¨ãã¾ãï¼
#include "eval.h"
ããã«ï¼ main()
é¢æ°ã«ããï¼
do_cross_validation();
ã®è¡ã以ä¸ã«ç½®æãã¾ãï¼
double cv = binary_class_cross_validation(&prob, ¶m, nr_fold); printf("Cross Validation = %g%%\n",100.0*cv);
predict.c ã®ä¿®æ£
ãtrain.cãåæ§ï¼ãpredict.cãã®å é ã«ä»¥ä¸ã®1è¡ã追è¨ãã¾ãï¼
#include "eval.h"
ããã«ï¼ main()
é¢æ°ã«ããï¼
do_predict(input, output);
ã®è¡ã以ä¸ã«ç½®æãã¾ãï¼
binary_class_predict(input, output);
eval.cpp ã®ä¿®æ£
ãeval.cppãã®ä»¥ä¸ã®è¡ã® auc
ã®é¨åãåºåããããè©ä¾¡å°ºåº¦ã«å¤æ´ãã¾ãï¼
double (*validation_function)(const dvec_t&, const ivec_t&) = auc;
æå®ã§ããã®ã¯ä»¥ä¸ã®å¤ã§ãï¼
accuracy
, auc
, precision
, recall
, fscore
, bac
Få¤ãåºåããããå ´å㯠fscore
ãæå®ãã¾ãï¼
ã³ã³ãã¤ã«ãã
LIBLINEAR ãåã³ã³ãã¤ã«ãã¾ãï¼
$ make clean $ make
ããã§å¥ã®è©ä¾¡å°ºåº¦ã使ã£ã cross validation ãã§ããããã«ãªãã¾ãï¼
試ãã«ãã£ã¦ã¿ã¾ãããï¼
$ ./train -v 5 heart_scale ......* optimization finished, #iter = 68 Objective value = -100.355195 nSV = 155 ......* optimization finished, #iter = 69 Objective value = -91.741174 nSV = 150 ......**. optimization finished, #iter = 70 Objective value = -99.387037 nSV = 160 ......** optimization finished, #iter = 69 Objective value = -97.614512 nSV = 154 ......* optimization finished, #iter = 68 Objective value = -87.859201 nSV = 150 F-score = 0.808696 Cross Validation = 80.8696%
確ãã« Få¤ (F-score) ãåºåãããããã«ãªãã¾ããï¼
ã¾ã¨ã
LIBLINEAR ã® cross validation ã«ä½¿ãè©ä¾¡å°ºåº¦ãå¤æ´ããæ¹æ³ã解説ãã¾ããï¼
ææ¨ãå¤æ´ãã度ã«åã³ã³ãã¤ã«ã®å¿
è¦ãããã®ãè¥å¹²ããã¯ã§ããï¼ããã§ãç°¡åã«ã§ããã®ã¯ããã§ããï¼