GAMES-UChile / mogptk

Multi-Output Gaussian Process Toolkit
MIT License
164 stars 43 forks source link

Examples Not Working (Referencing Objects from Older Version?) #26

Closed jimmyrisk closed 3 years ago

jimmyrisk commented 3 years ago

Hi,

I'm specifically referring to Example 6: https://github.com/GAMES-UChile/mogptk/blob/master/examples/06_Custom_Kernels_and_Mean_Functions.ipynb

In trying to use a custom mean function, the code given simply does not work. This code

class Mean(mogptk.kernels.Mean):
    def __init__(self):
        super(Mean, self).__init__()
        self.coefficients = mogptk.kernels.Parameter([0.0, 0.0, 0.0])

    def __call__(self, X):
        coefs = self.coefficients()
        return coefs[0] + coefs[1] * X[:, 1] + coefs[2] * X[:, 1] ** 2

gives an error

Traceback (most recent call last):
  File "<input>", line 2, in <module>
AttributeError: module 'mogptk' has no attribute 'kernels'

However, after doing some debugging, it appears that changing kernels to gpr works. So,

class Mean(mogptk.gpr.Mean):
    def __init__(self):
        super(Mean, self).__init__()
        self.coefficients = mogptk.gpr.Parameter([0.0, 0.0, 0.0])

    def __call__(self, X):
        coefs = self.coefficients()
        return coefs[0] + coefs[1] * X[:, 1] + coefs[2] * X[:, 1] ** 2

seems to work correctly.

tdewolff commented 3 years ago

Thanks for the feedback! I have pushed through a fix, please let me know if that works well!

Fixed in https://github.com/GAMES-UChile/mogptk/commit/4ef4aaa9a530a4073138cdace1ee349815d641d0