Using bayes functions in context?

Q&A's, tips, howto's
Locked
methodic
Posts: 58
Joined: Tue May 10, 2005 5:04 am

Using bayes functions in context?

Post by 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.

Code: Select all

> (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)

Code: Select all

> (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
Posts: 429
Joined: Sun Dec 02, 2007 5:10 pm
Contact:

Re: Using bayes functions in context?

Post by itistoday »

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:

Code: Select all

> (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:

Code: Select all

> (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
Posts: 58
Joined: Tue May 10, 2005 5:04 am

Re: Using bayes functions in context?

Post by methodic »

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

Locked