dfm / george

Fast and flexible Gaussian Process regression in Python
http://george.readthedocs.io
MIT License
445 stars 128 forks source link

general matern kernels #134

Open dhruvbalwada opened 3 years ago

dhruvbalwada commented 3 years ago

Hello, I am using the george package to model ocean flows and do spectral estimation from limited data. One way to do this by trying to fit a general matern kernel (or sum of 2-3 general matern kernels). I see that there is a MaternGeneral.yml.example in the kernels folder. I was wondering if this has actually been implemented and tried? or if there was some reason that it was not included in the documentation?

Also, I am working with 2D or 3D data, should I transition over to using GPyTorch, as recommended in #128 ? Specially considering, that I am just starting to get involved in GP modelling.

dfm commented 3 years ago

The general Matern is not part of george since it requires boost. If you have boost installed, you should be able to get that implementation by cloning george, renaming the MaternGeneral.yml.example file by removing the .example, and re-installing. I should note that fitting for nu is not supported by this kernel, but you could at least try several values.

Switching to GPyTorch is probably better long term because it gets more support, but it looks like they don't have a general Matern implemented either (only 1/2, 3/2 and 5/2, same as george!).

j-faria commented 3 years ago

Hi Dan, I'm having some trouble with this (and with implementing new kernels in general). After renaming the MaternGeneral.yml.example file and recompiling (with python setup.py develop), several of the tests don't pass:

...george-0.3.1-py3.7-linux-x86_64.egg/george/kernels.py:66: AttributeError
========================================================= short test summary info ==========================================================
FAILED tests/test_gp.py::test_gradient[BasicSolver-None] - AttributeError: kernel
FAILED tests/test_gp.py::test_gradient[BasicSolver-0.1] - AttributeError: kernel
FAILED tests/test_gp.py::test_gradient[HODLRSolver-None] - AttributeError: kernel
FAILED tests/test_gp.py::test_gradient[HODLRSolver-0.1] - AttributeError: kernel
FAILED tests/test_gp.py::test_apply_inverse[BasicSolver] - AttributeError: kernel
FAILED tests/test_gp.py::test_apply_inverse[HODLRSolver] - AttributeError: kernel
FAILED tests/test_gp.py::test_predict_single[BasicSolver] - AttributeError: kernel
FAILED tests/test_gp.py::test_predict_single[HODLRSolver] - AttributeError: kernel
FAILED tests/test_kernels.py::test_dtype - AttributeError: kernel
FAILED tests/test_kernels.py::test_kernel[kernel0] - AttributeError: 'BaseConstantKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel1] - AttributeError: 'BaseConstantKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel2] - AttributeError: 'BaseConstantKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel10] - AttributeError: 'BaseExpSine2Kernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel11] - AttributeError: 'BaseExpSine2Kernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel12] - AttributeError: 'BaseExpSine2Kernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel13] - AttributeError: 'BaseExpSine2Kernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel14] - AttributeError: 'BaseExpSine2Kernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel15] - AttributeError: 'BaseExpSine2Kernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel16] - ValueError: unrecognized kernel
FAILED tests/test_kernels.py::test_kernel[kernel17] - ValueError: unrecognized kernel
FAILED tests/test_kernels.py::test_kernel[kernel18] - ValueError: unrecognized kernel
FAILED tests/test_kernels.py::test_kernel[kernel19] - ValueError: unrecognized kernel
FAILED tests/test_kernels.py::test_kernel[kernel26] - AttributeError: 'BasePolynomialKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel27] - AttributeError: 'BasePolynomialKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel28] - AttributeError: 'BasePolynomialKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel29] - AttributeError: 'BasePolynomialKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel30] - AttributeError: 'BasePolynomialKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_kernel[kernel31] - AttributeError: kernel
FAILED tests/test_kernels.py::test_kernel[kernel32] - AttributeError: kernel
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel0] - AttributeError: 'BaseConstantKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel1] - AttributeError: 'BaseConstantKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel2] - AttributeError: 'BaseConstantKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel10] - AttributeError: 'BaseExpSine2Kernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel11] - AttributeError: 'BaseExpSine2Kernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel12] - AttributeError: 'BaseExpSine2Kernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel13] - AttributeError: 'BaseExpSine2Kernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel14] - AttributeError: 'BaseExpSine2Kernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel15] - AttributeError: 'BaseExpSine2Kernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel16] - ValueError: unrecognized kernel
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel17] - ValueError: unrecognized kernel
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel18] - ValueError: unrecognized kernel
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel19] - ValueError: unrecognized kernel
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel26] - AttributeError: 'BasePolynomialKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel27] - AttributeError: 'BasePolynomialKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel28] - AttributeError: 'BasePolynomialKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel29] - AttributeError: 'BasePolynomialKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel30] - AttributeError: 'BasePolynomialKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel31] - AttributeError: kernel
FAILED tests/test_kernels.py::test_x_gradient_kernel[kernel32] - AttributeError: kernel
FAILED tests/test_kernels.py::test_stationary[ExpKernel-kwargs0] - AttributeError: 'BaseExpKernel' object has no attribute 'kernel'
FAILED tests/test_kernels.py::test_stationary[RationalQuadraticKernel-kwargs4] - IndexError: boolean index did not match indexed array al...
FAILED tests/test_kernels.py::test_stationary[RationalQuadraticKernel-kwargs5] - IndexError: boolean index did not match indexed array al...
FAILED tests/test_kernels.py::test_stationary[RationalQuadraticKernel-kwargs6] - IndexError: boolean index did not match indexed array al...
FAILED tests/test_metrics.py::test_general_metric - AttributeError: kernel
FAILED tests/test_metrics.py::test_axis_algined_metric - AttributeError: kernel
FAILED tests/test_modeling.py::test_gp_mean - AttributeError: kernel
FAILED tests/test_modeling.py::test_gp_callable_mean - AttributeError: kernel
FAILED tests/test_modeling.py::test_gp_white_noise - AttributeError: kernel
FAILED tests/test_modeling.py::test_gp_callable_white_noise - AttributeError: kernel
FAILED tests/test_pickle.py::test_pickle[BasicSolver-True] - AttributeError: kernel
FAILED tests/test_pickle.py::test_pickle[HODLRSolver-False] - AttributeError: 'BaseConstantKernel' object has no attribute 'metric'
FAILED tests/test_solvers.py::test_basic_solver - AttributeError: kernel
FAILED tests/test_solvers.py::test_hodlr_solver - AttributeError: 'BaseConstantKernel' object has no attribute 'metric'
FAILED tests/test_solvers.py::test_strange_hodlr_bug - AttributeError: 'BaseConstantKernel' object has no attribute 'metric'
FAILED tests/test_tutorial.py::test_tutorial - AttributeError: kernel
================================================= 65 failed, 37 passed, 1 xfailed in 3.56s =================================================

I've also tried just copying the Constant.yml to a new file with a different name and the same thing happens.

j-faria commented 3 years ago

Nevermind, this probably had something to do with me doing setup.py develop instead of install and some old files lurking around. After removing the build directory, the problem is solved.