Personal tools
You are here: Home Discussion

Discussion

Up to the Bugs Forum
Please feel free to communicate anything you feel could help this project move on. You can receive an email each time a new message is posted by setting up your personal preferences.

Learning

Posted by Francois at June 21. 2007
Hello!

There are errors in the learning (EM and SEM) algorithms of the downloadable version. I uploaded (see Development) a version that works. Please look at the tutorials for more details.

François
Posted by sergioroa at July 19. 2007
I am using Linux and I am not able to use the numarray package you uploaded (seems to function for Windows?). Which version of numarray is that? I am using numarray 1.5.2. but still I am getting this error running the example in the tutorial and using Python2.4.

c
s
w
r
['w', 'r', 's']
EM iteration: 1
Traceback (most recent call last):
File "SEMLearning.py", line 67, in ?
struct_engine.SEMLearningApprox(cases)
File "/home/HU.shadow/sergior/python/lib/python2.4/site-packages/OpenBayes/learning.py", line 371, in SEMLearningApprox
self.EMLearning(cases, 15)
File "/home/HU.shadow/sergior/python/lib/python2.4/site-packages/OpenBayes/learning.py", line 113, in EMLearning
while self.hasntConverged(old, new, precision) and iter < max_iter:
File "/home/HU.shadow/sergior/python/lib/python2.4/site-packages/OpenBayes/learning.py", line 319, in hasntConverged
return not na.alltrue([na.allclose(v.distribution, new.v[v.name].distribution, atol=precision) for v in old.v.values()])
File "/home/HU.shadow/sergior/python/lib/python2.4/site-packages/numarray/numarraycore.py", line 1518, in allclose
x, y = asarray(array1), asarray(array2)
File "/home/HU.shadow/sergior/python/lib/python2.4/site-packages/numarray/numarraycore.py", line 434, in asarray
return array(seq, type=type, typecode=typecode, copy=0, dtype=dtype)
File "/home/HU.shadow/sergior/python/lib/python2.4/site-packages/numarray/numarraycore.py", line 425, in array
return fromlist(sequence,type,shape)
File "/home/HU.shadow/sergior/python/lib/python2.4/site-packages/numarray/numarraycore.py", line 248, in fromlist
if not len(seq) and type is None:
TypeError: len() of unsized object

Using Python2.5 I get only a floating point exception
Posted by sergioroa at July 19. 2007
If I comment the line 116:

old = copy.deepcopy(new)

this error is not shown anymore. However, this does not seem to be logical for the purpose of testing if the algorithm has converged and it always runs till the maximal number of iterations.
Posted by sergioroa at July 19. 2007
I forgot to say that using Python 2.5 the floating point error remains.
Posted by sergioroa at July 19. 2007
I solved finally the problem by changing the code in the EMLearning function as follows:

old = None
new = self.BNet
precision = 0.05
while self.hasntConverged(old, new, precision) and iter < max_iter:
iter += 1
print 'EM iteration: ', iter
old = new
self.LearnEMParams(cases)
# reinitialize the JunctionTree to take effect of new parameters learned
self.engine.Initialization()
# self.engine.GlobalPropagation()
new = self.BNet
Posted by sergioroa at July 19. 2007
Well, looking more carefully my solution, I realized it is also not correct :-(
Powered by Ploneboard

Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: