1

I'm using libSVM, svmtrain function in matlab takes less time than C. Although C -in general- is much faster than matlab. Both classifiers take the same parameters and return the same number of SVMs with the same number of iterations.

Here is the code in both: Matlab:

t1=cputime; model = svmtrain(Labels,data, '-h 0 -s 0 -c 0.025 -n 0.01 -b 1 -t 0 -d 1 -p 0.001'); t2=cputime; fprintf('Elapsed time=%.3f\n',t2-t1)

AND C code:

    clock_t begin = clock();
    model = svm_train(&prob,&param);    
    clock_t end = clock();;
    double time_spent = (double)(end - begin) / double(CLOCKS_PER_SEC);

1 Answers1

1

As you are using the option -b 1 to obtain probabilities:

  • libsvm will use Platt scaling to obtain these probabilities with the usage of cross-validation
  • cross-validation always splits the data randomly
  • Within C, the default seed of 1 will be used
  • Maybe the Matlab interface will use a seed based on time (or any other)
    • As a first step, i would set Matlabs global seed to 1 and do the same for C; then measure again

As indicated in my comment, it would be wise to do much more tests. Even if the seeds are different (a possibility), the average of many many runs should be the same as the same code is used!

See also this question where some other possibilites for different behaviour are listed (you said you obtained the same number of SVs; but maybe the behaviour is different internally)

Community
  • 1
  • 1
sascha
  • 32,238
  • 6
  • 68
  • 110