[kernel] plot_ard added (some other fixes as well)

This commit is contained in:
Max Zwiessele 2015-10-09 16:07:57 +01:00
parent e3617942d4
commit d2d8a62d2d
14 changed files with 371 additions and 337 deletions

View file

@ -1,35 +1,54 @@
# Copyright (c) 2014, GPy authors (see AUTHORS.txt).
# Licensed under the BSD 3-clause license (see LICENSE.txt)
try:
#===========================================================================
# Load in your plotting library here and
# save it under the name plotting_library!
# This is hooking the library in
# for the usage in GPy:
from ..util.config import config
lib = config.get('plotting', 'library')
if lib == 'matplotlib':
import matplotlib
from .matplot_dep import plot_definitions
plotting_library = plot_definitions.MatplotlibPlots()
if lib == 'plotly':
import plotly
from .plotly_dep import plot_definitions
plotting_library = plot_definitions.PlotlyPlots()
#===========================================================================
except (ImportError, NameError):
raise
import warnings
warnings.warn(ImportWarning("{} not available, install newest version of {} for plotting".format(lib, lib)))
config.set('plotting', 'library', 'none')
current_lib = [None]
def change_plotting_library(lib):
try:
#===========================================================================
# Load in your plotting library here and
# save it under the name plotting_library!
# This is hooking the library in
# for the usage in GPy:
if lib == 'matplotlib':
import matplotlib
from .matplot_dep.plot_definitions import MatplotlibPlots
current_lib[0] = MatplotlibPlots()
if lib == 'plotly':
import plotly
from .plotly_dep.plot_definitions import PlotlyPlots
current_lib[0] = PlotlyPlots()
if lib == 'none':
current_lib[0] = None
#===========================================================================
except (ImportError, NameError):
import warnings
warnings.warn(ImportWarning("{} not available, install newest version of {} for plotting".format(lib, lib)))
config.set('plotting', 'library', 'none')
from ..util.config import config
lib = config.get('plotting', 'library')
change_plotting_library(lib)
def plotting_library():
return current_lib[0]
def show(figure, **kwargs):
"""
Show the specific plotting library figure, returned by
add_to_canvas().
kwargs are the plotting library specific options
for showing/drawing a figure.
"""
return plotting_library().show_canvas(figure, **kwargs)
if config.get('plotting', 'library') is not 'none':
# Inject the plots into classes here:
# Already converted to new style:
from . import gpy_plot
from ..core import GP
GP.plot_data = gpy_plot.data_plots.plot_data
GP.plot_errorbars_trainset = gpy_plot.data_plots.plot_errorbars_trainset
@ -40,10 +59,10 @@ if config.get('plotting', 'library') is not 'none':
GP.plot = gpy_plot.gp_plots.plot
GP.plot_f = gpy_plot.gp_plots.plot_f
GP.plot_magnification = gpy_plot.latent_plots.plot_magnification
from ..core import SparseGP
SparseGP.plot_inducing = gpy_plot.data_plots.plot_inducing
from ..models import GPLVM, BayesianGPLVM, bayesian_gplvm_minibatch, SSGPLVM, SSMRD
GPLVM.plot_latent = gpy_plot.latent_plots.plot_latent
GPLVM.plot_scatter = gpy_plot.latent_plots.plot_latent_scatter
@ -61,11 +80,11 @@ if config.get('plotting', 'library') is not 'none':
SSGPLVM.plot_scatter = gpy_plot.latent_plots.plot_latent_scatter
SSGPLVM.plot_inducing = gpy_plot.latent_plots.plot_latent_inducing
SSGPLVM.plot_steepest_gradient_map = gpy_plot.latent_plots.plot_steepest_gradient_map
from ..kern import Kern
Kern.plot_covariance = gpy_plot.kernel_plots.plot_covariance
Kern.plot_covariance = gpy_plot.kernel_plots.plot_ARD
Kern.plot_ARD = gpy_plot.kernel_plots.plot_ARD
from ..inference.optimization import Optimizer
Optimizer.plot = gpy_plot.inference_plots.plot_optimizer
# Variational plot!
# Variational plot!