to_dict() and from_dict() functionality for Coregionalize Kernel and MixedNoise Likelihood class, appveyor CI resurrected (#951)

This PR adds two main things to GPy:
- to- and from-dict functions for the kernels listed belop
- a fix for the appveyor CI
Please see the squashed commit messages listed below.
Authors: @gehbiszumeis @ppk42 respectively
Reviewer: @ekalosak 

---
* new: added to_dict() method to Coregionalize kernel class

* new: added to_dict() method to MixedNoise likelihood class

* fix: made Y_metadata dict content serializable

* fix: typo

* added additional needed parameters to to_dict() method for Coregionalize kernel + added _build_from_input dict method

* new: added possibility to build MixedNoise likelihood from input_dict

* Y_metadata conversion from serializable to np.array when loading from dict

* fix: rework Y_metadata part for compatibility with unittests !minor

* conda cleanup in appveyors pipeline

* conda clean up after conda update

* conda clean before conda update

* try pinning packages for conda

* revert all conda changes

* conda clean all (not only packages)

* use conda update anaconda

* pin conda package

* pin conda package

* try installing charset-normalizer beforehand

* try to get from conda-forge

* revert all conda changes

* Try to fix the conda update challange.

See: https://community.intel.com/t5/Intel-Distribution-for-Python/Conda-update-Conda-fails/td-p/1126174

It is just a try for a different context/(conda version).

* Still fixing build error on appveyor

I also use a newer miniconda version for greater python versions.

* Update appveyor.yml

Thinking it over it decided to use miniconda38 for all python versions unless python 3.5.

* revert miniconda versioning changes

* adjust GPy version in appveyor.yml

* 1st attempt bring the appveyor build to life again

* #955 fixing ci build on appveyor

After bringing the miniconda env to work again, the wrong matplotlib version was used. This commit should fix that.

* #955 Fix CI build

Freezing numpy and scipy was a bad idea.
I freeze matplotlib  dependend  on the python version only.

* add: built_from_dict method for White Kernel

Co-authored-by: Peter Paul Kiefer <ppk42@users.noreply.github.com>
Co-authored-by: Peter Paul Kiefer <dafisppk@gmail.com>
This commit is contained in:
gehbiszumeis 2021-12-09 20:14:27 +01:00 committed by GitHub
parent 3e19a85575
commit bb1bc50886
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 84 additions and 12 deletions

View file

@ -134,3 +134,28 @@ class Coregionalize(Kern):
def gradients_X_diag(self, dL_dKdiag, X):
return np.zeros(X.shape)
def to_dict(self):
"""
Convert the object into a json serializable dictionary.
Note: It uses the private method _save_to_input_dict of the parent.
:return dict: json serializable dictionary containing the needed information to instantiate the object
"""
input_dict = super(Coregionalize, self)._save_to_input_dict()
input_dict["class"] = "GPy.kern.Coregionalize"
# W and kappa must be serializable
input_dict["W"] = self.W.values.tolist()
input_dict["kappa"] = self.kappa.values.tolist()
input_dict["output_dim"] = self.output_dim
return input_dict
@staticmethod
def _build_from_input_dict(kernel_class, input_dict):
useGPU = input_dict.pop('useGPU', None)
# W and kappa must be converted back to numpy arrays
input_dict['W'] = np.array(input_dict['W'])
input_dict['kappa'] = np.array(input_dict['kappa'])
return Coregionalize(**input_dict)

View file

@ -68,6 +68,11 @@ class White(Static):
input_dict = super(White, self)._save_to_input_dict()
input_dict["class"] = "GPy.kern.White"
return input_dict
@staticmethod
def _build_from_input_dict(kernel_class, input_dict):
useGPU = input_dict.pop('useGPU', None)
return White(**input_dict)
def K(self, X, X2=None):
if X2 is None: