marionmari / pyGPs

pyGPs is a library containing an object-oriented python implementation for Gaussian Process (GP) regression and classification.
Other
213 stars 64 forks source link

python 3 compatibility #17

Closed adrinjalali closed 8 years ago

adrinjalali commented 9 years ago

Hi,

I managed to get it work with python 3, and all the tests except one pass now. I've added some code to print out some debug info, and somewhere an array is empty which is not supposed to be (Core/cov.py line 350). It would be nice if someone could help me fix this issue, and maybe have this code on a branch for python 3 if there's a plan for it.

$ python3 -u unit_test_model.py 
Running unit tests(about 5 min)...
testing GP classification...
.testing GP sparse classification...
()
(120, 2)
()
(120, 2)
tuple index out of range
Traceback (most recent call last):
  File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/opt.py", line 242, in findMin
    thisopt = minimize.run(self._nlzAnddnlz, hypInArray, length=-40)
  File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Optimization/minimize.py", line 62, in run
    result = f(X, *args)
  File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/opt.py", line 66, in _nlzAnddnlz
    nlZ, dnlZ, post = self.model.getPosterior()
  File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/gp.py", line 331, in getPosterior
    post, nlZ, dnlZ = self.inffunc.evaluate(self.meanfunc, self.covfunc, self.likfunc, self.x, self.y, 3)
  File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/inf.py", line 819, in evaluate
    diagK,Kuu,Ku = covfunc.getCovMatrix(x=x, mode='train')  # evaluate the covariance matrix
  File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/cov.py", line 352, in getCovMatrix
    assert(xu.shape[1] == x.shape[1])

...

    ======================================================================
ERROR: test_GPC_FITC (__main__.ModelTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "unit_test_model.py", line 109, in test_GPC_FITC
    model.optimize(self.xc, self.yc)
  File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/gp.py", line 270, in optimize
    optimalHyp, optimalNlZ = self.optimizer.findMin(self.x, self.y, numIters = numIterations)
  File "/TL/stat_learn/work/ajalali/opt-wheezy/lib/python3.3/site-packages/pyGPs-1.3.1-py3.3.egg/pyGPs/Core/opt.py", line 253, in findMin
    raise Exception("Over half of the trails failed for minimize")
Exception: Over half of the trails failed for minimize

----------------------------------------------------------------------
Ran 4 tests in 10.816s

FAILED (errors=1)
shansfolder commented 9 years ago

Thank you for working on python 3!

I think the problem lies in "xu", it looks like you are passing empty inducing point to the model.

So the assertion failed xu.shape[1] == x.shape[1]

In our package, there should be default inducing points if the user don't specify himself. Did you have this implemented in your python3 version?

mathDR commented 9 years ago

@shansfolder Did you want to close this? Merge it? It has been open for a while

shansfolder commented 8 years ago

I will close this issue now, as there is no further information provided and currently we don't have a plan of migration to python 3. If you have new comments on it, please open a new issue.