Search code examples
pythonsubprocesslibsvm

Running libsvm with subprocess don't create a model


I'm trying to generate 20 models with svm-train. This script work and print cross validation values but no model files are created. I can't figure out why, any idea ?

for i in range(1,21):
    format_libsvm(data,"test",i) # create a data file called test 
    data = "test"
    model = "model"+str(i)
    batcmd = "./libsvm-3.21/svm-train -b 1 -v 10 "+data+".scale "+model
    subprocess.call(batcmd, shell=True)
    regex_CV = 'Cross Validation Accuracy = ([0-9\.]+)%' 
    result_re = re.search(regex_CV,result)
    print (num2aa[i]+" "+result_re.group(1))

I really appreciate any help you can provide.


Solution

  • "Cross validation is used for selecting good parameters. After finding them, you want to re-train the whole data without the -v option." csie.ntu.edu.tw/~cjlin/libsvm/faq.html#f501

    That's why i have no model files. My bad.