Can I change the SVM classifier output from 'true', 'false' to 0,1?
Afficher commentaires plus anciens
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
Réponses (2)
Walter Roberson
le 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
le 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
Catégories
En savoir plus sur Language Support dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!