Tools for liblinear. For libsvm, there are useful tools. However, they does not fit to liblinear. We need to rewrite them for liblinear. That's very inconvenient. Thus, I opened tools for liblinear.
- scaling feature value
- grid searching of hyperparameter C and xi
- feature selection tuning on F-value
- liblinear: I confirmed at version 1.94
- svm-scale: svm-scale exists in libsvm package. svm-scale is need to scale feature values
use ./tools/liblin_easy.py
#you can re-write for your environment
svmscale_exe='../svm-scale';
liblinear_exe='../liblinear-1.94/train';
grid_py='/home/kensuke-mi/opt/libsvm-3.17/tools/grid.py';
import re, subprocess, os, sys;
#you can re-write for your environment
sys.path.append('../liblinear-1.94/python/');
import liblinear, liblinearutil;
train_pathname='../heart_scale'
test_pathname='../heart_scale'
test01=Liblin_easy(train_pathname,test_pathname)
To scale feature values
test01.scalling_value()
To parameter tuning with grid search. You can tune parameters for other files, if you rewrite argument of this method.
test01.grid_search(train_pathname)
If you use easy_tuning()
, it automatically do scaling and grid search on training file
test01.easy_tuning()