Saurabh Singhvi wrote:
>
Hi all,

I used the Algorithm::NaiveBayes from CPAN. Now it's all working fine
on the syntax. The problem is that I cannot get the 'result'. I trained the
algorithm with some attributes and provided the labels alongwith using
add_instance. And then trained it with train(). Now, to predict I used the
same syntax as given in the docs, and provided attributes in the same
manner as I used with add_instance. Now If i do

print %$result

I get the labels and their corresponding scores, which is probably what
it should be, seeing from the docs. So, what I cannot understand is, where
is the result / predicted value stored??? and how do i get it??


There is no single result Surabh, the hash tells you how well each of the
category labels applies to the attribute set you specified in the call to
predict(). The nearer the key value is to 1 the better the category corresponds
with the attributes. You could choose one of the labels returned byt simply
picking the one with the highest key value, but you really need to look at the
whole data set as even the best match may be a very bad one, or there may be
several very good ones.

Display your results with

printf "%s => %s\n" $_, $result->{$_} foreach keys %$result;

HTH,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to