cjlin1 / libsvm

LIBSVM -- A Library for Support Vector Machines
https://www.csie.ntu.edu.tw/~cjlin/libsvm/
BSD 3-Clause "New" or "Revised" License
4.52k stars 1.64k forks source link

ERROR: to use other evaluation criteria, labels must be +1/-1 #183

Closed vincentjytsai-nycu closed 2 years ago

vincentjytsai-nycu commented 2 years ago

Hi,

After adding the plug-in "eval.h" and "eval.cpp" used in crossvalidation with different criteria (AUC, F-score, etc.), there is an error when running "svm-predict" with heart_scale (the example data file): ERROR: to use other evaluation criteria, labels must be +1/-1 image

I'm wondering what is the problem. Any help is appreciated. Thanks!

cjlin1 commented 2 years ago

Did you also copy the new Makefile and rebuild the file? I can run it without problem:

$ make g++ -Wall -Wconversion -O3 -fPIC -c eval.cpp -o eval.o g++ -Wall -Wconversion -O3 -fPIC svm-train.c svm.o eval.o -o svm-train -lm g++ -Wall -Wconversion -O3 -fPIC svm-predict.c svm.o eval.o -o svm-predict -lm $ ./svm-train heart_scale * optimization finished, #iter = 162 nu = 0.431029 obj = -100.877288, rho = 0.424462 nSV = 132, nBSV = 107 Total nSV = 132 $ ./svm-predict heart_scale heart_scale.model o Accuracy = 86.6667% (234/270) (classification)

On 2022-04-20 03:13, vincentjytsai-nycu wrote:

Hi,

After adding the plug-in "eval.h" and "eval.cpp" used in crossvalidation with different criteria (AUC, F-score, etc.), there is an error when running "svm-predict" with heart_scale (the example data file): ERROR: to use other evaluation criteria, labels must be +1/-1 [1]

I'm wondering what is the problem. Any help is appreciated. Thanks!

-- Reply to this email directly, view it on GitHub [2], or unsubscribe [3]. You are receiving this because you are subscribed to this thread.Message ID: @.> [ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/cjlin1/libsvm/issues/183", "url": "https://github.com/cjlin1/libsvm/issues/183", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

Links:

[1] https://user-images.githubusercontent.com/89758515/164078427-6aca693f-3556-4c54-90c6-b072a4c3eaac.png [2] https://github.com/cjlin1/libsvm/issues/183 [3] https://github.com/notifications/unsubscribe-auth/ABI3BHXCDGRGK32TBRCKBDLVF4AVPANCNFSM5TZZJCKQ

vincentjytsai-nycu commented 2 years ago

I indeed copied the new Makefile and recompile the code. But the situation remains the same...... image

cjlin1 commented 2 years ago

Did you exactly follow what I did? Please show me the full log of what you did

On 2022-04-20 05:47, vincentjytsai-nycu wrote:

I indeed copied the new Makefile and recompile the code. But the situation remains the same...... [1]

-- Reply to this email directly, view it on GitHub [2], or unsubscribe [3]. You are receiving this because you commented.Message ID: @.> [ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/cjlin1/libsvm/issues/183#issuecomment-1103204165", "url": "https://github.com/cjlin1/libsvm/issues/183#issuecomment-1103204165", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

Links:

[1] https://user-images.githubusercontent.com/89758515/164107271-b76d1657-4102-4c8b-981b-c4f49b8f2be2.png [2] https://github.com/cjlin1/libsvm/issues/183#issuecomment-1103204165 [3] https://github.com/notifications/unsubscribe-auth/ABI3BHRGGZEFV3EFFQC6XV3VF4SY5ANCNFSM5TZZJCKQ

vincentjytsai-nycu commented 2 years ago
  1. I have updated the Makefile as the instruction says. image

  2. I have modified svm-train.cpp and svm-predict following the instruction. The header file "eval.h" is also included. image image

  3. Then I compiled the code and executed the commands as you did, but the error still occurs...... image

cjlin1 commented 2 years ago

I see. This line if (labels[j] != 1 && labels[j] == -1)

should be

if (labels[j] != 1 && labels[j] != -1)

I have updated the file. Please download it again. Thanks for pointing out the problem

On 2022-04-20 06:08, vincentjytsai-nycu wrote:

*

I have updated the Makefile as the instruction says. [1] *

I have modified svm-train.cpp and svm-predict following the instruction. The header file "eval.h" is also included. [2] [3] *

Then I compiled the code and executed the commands as you did, but the error still occurs...... [4]

-- Reply to this email directly, view it on GitHub [5], or unsubscribe [6]. You are receiving this because you commented.Message ID: @.> [ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/cjlin1/libsvm/issues/183#issuecomment-1103216370", "url": "https://github.com/cjlin1/libsvm/issues/183#issuecomment-1103216370", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ]

Links:

[1] https://user-images.githubusercontent.com/89758515/164108703-146f60fd-44b2-4e66-935a-b0dcce9e2f03.png [2] https://user-images.githubusercontent.com/89758515/164109296-e034cc45-255f-4d73-9b5d-a74da105c0ca.png [3] https://user-images.githubusercontent.com/89758515/164109408-78a5536e-a676-499d-9e61-b1bfbdd85fd9.png [4] https://user-images.githubusercontent.com/89758515/164109761-c5eb6f89-6adb-4a23-83e7-16863c3f09ba.png [5] https://github.com/cjlin1/libsvm/issues/183#issuecomment-1103216370 [6] https://github.com/notifications/unsubscribe-auth/ABI3BHQ4V5SOQC65S7DFOJTVF4VFLANCNFSM5TZZJCKQ

vincentjytsai-nycu commented 2 years ago

Thanks. The result can be successfully printed out after updating eval.cpp. image