Using bayes functions in context?

Started by methodic, December 18, 2009, 09:19:04 AM

Previous topic - Next topic

methodic

I am running into this issue -- when trying to use the bayes functions in context MAIN, it works as expected. When trying to use these in a defined function, I am getting an error with bayes-query.


> (bayes-train '(A A B C C) '(A B B C C C) 'L)
(5 6)
> (bayes-query '(A C) L)
(0.579614219 0.420385781)

> (context 'TEST)
TEST
TEST> (bayes-train '(A A B C C) '(A B B C C C) 'L)
(5 6)
TEST> (bayes-query '(A C) L)

ERR: context expected in function bayes-query : TEST:L


Anyone have any insight as to why this is happening? Am I not defining something properly?



Thanks in advance.

itistoday

#1
I think it's because since there is no existing L context, the symbol 'L inside of a different context is a symbol inside of that context, and context symbols must be in the MAIN context.



There are two ways around this:



#1: define the context first:


> (context 'L)
L
L> (context 'TEST)
TEST
TEST> (bayes-train '(A A B C C) '(A B B C C C) 'L)
(5 6)
TEST> (bayes-query '(A C) L)
(0.579614219 0.420385781)


#2: context-qualify 'L inside of 'TEST:


> (context 'TEST)
TEST
TEST> (bayes-train '(A A B C C) '(A B B C C C) 'MAIN:L)
(5 6)
TEST> (bayes-query '(A C) L)
(0.579614219 0.420385781)
Get your Objective newLISP groove on.

methodic

#2
Thanks, I tried defining MAIN:K just without the tick. That solution worked. :)