Can I change the SVM classifier output from 'true', 'false' to 0,1?
Show older comments
Hi Can I change the SVM classifier output from 'true', 'false' to 0,1? as i am currently get the output in the form of true and false and it is better for my problem domain to have it in 0 and 1. i write a code to string compare but it takes too long as i have a great amount of data. so if there is anyway to change the output of the classifier to give 0 for the 'false' classifications and 1 for 'true' ones. thank you for your time regards Emad
Answers (2)
Walter Roberson
on 22 Jan 2013
Add 0 to your output.
true + 0
is 1, and
false + 0
is 0
Or, for many purposes, you can just go ahead and use the logical values in numeric statements.
true * 5 / (false + 1)
Not everything, though: for example, exp(false) will not work, but exp(false+0) will work.
Shashank Prasanna
on 22 Jan 2013
You can cast it to double, try this:
x = [true false true true];
y = double(x);
>> whos
Name Size Bytes Class Attributes
x 1x4 4 logical
y 1x4 32 double
Categories
Find more on Language Support in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!