mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-18 13:55:14 +02:00
Changes in plotting functions.
This commit is contained in:
parent
f7d2fc6ca4
commit
5e2baf1919
5 changed files with 71 additions and 31 deletions
|
|
@ -7,7 +7,7 @@ import pylab as pb
|
|||
from .. import kern
|
||||
from ..core import model
|
||||
from ..util.linalg import pdinv,mdot
|
||||
from ..util.plot import gpplot,x_frame, Tango
|
||||
from ..util.plot import gpplot,x_frame1D,x_frame2D, Tango
|
||||
from ..likelihoods import EP
|
||||
|
||||
class GP(model):
|
||||
|
|
@ -175,7 +175,7 @@ class GP(model):
|
|||
return mean, _5pc, _95pc
|
||||
|
||||
|
||||
def plot_GP(self,samples=0,plot_limits=None,which_data='all',which_functions='all',resolution=None,full_cov=False):
|
||||
def plot_internal(self,samples=0,plot_limits=None,which_data='all',which_functions='all',resolution=None,full_cov=False):
|
||||
"""
|
||||
Plot the GP's view of the world, where the data is normalised and the likelihood is Gaussian
|
||||
|
||||
|
|
@ -200,22 +200,49 @@ class GP(model):
|
|||
if which_data=='all':
|
||||
which_data = slice(None)
|
||||
|
||||
Xnew, xmin, xmax = x_frame(self.X, plot_limits=plot_limits)
|
||||
if self.X.shape[1] == 1:
|
||||
Xnew, xmin, xmax = x_frame1D(self.X, plot_limits=plot_limits)
|
||||
m,v = self._raw_predict(Xnew, slices=which_functions)
|
||||
gpplot(Xnew,m,m-np.sqrt(v),m+np.sqrt(v))
|
||||
pb.plot(self.X[which_data],self.likelihood.Y[which_data],'kx',mew=1.5)
|
||||
pb.xlim(xmin,xmax)
|
||||
elif X.shape[1]==2:
|
||||
resolution = resolution or 50
|
||||
Xnew, xmin, xmax,xx,yy = x_frame2D(self.X, plot_limits=plot_limits)
|
||||
m,v = self._raw_predict(Xnew, slices=which_functions)
|
||||
m = m.reshape(resolution,resolution)
|
||||
pb.contour(xx,yy,zz,vmin=zz.min(),vmax=zz.max(),cmap=pb.cm.jet)
|
||||
pb.scatter(Xorig[:,0],Xorig[:,1],40,Yorig,linewidth=0,cmap=pb.cm.jet,vmin=zz.min(),vmax=zz.max())
|
||||
pb.xlim(xmin[0],xmax[0])
|
||||
pb.ylim(xmin[1],xmax[1])
|
||||
else:
|
||||
raise NotImplementedError, "Cannot define a frame with more than two input dimensions"
|
||||
|
||||
m,v = self._raw_predict(Xnew, slices=which_functions)
|
||||
gpplot(Xnew,m,m-np.sqrt(v),m+np.sqrt(v))
|
||||
pb.plot(self.X[which_data],self.likelihood.Y[which_data],'kx',mew=1.5)
|
||||
pb.xlim(xmin,xmax)
|
||||
|
||||
def plot_output(self,samples=0,plot_limits=None,which_data='all',which_functions='all',resolution=None,full_cov=False):
|
||||
def plot(self,samples=0,plot_limits=None,which_data='all',which_functions='all',resolution=None,full_cov=False):
|
||||
if which_functions=='all':
|
||||
which_functions = [True]*self.kern.Nparts
|
||||
if which_data=='all':
|
||||
which_data = slice(None)
|
||||
Xnew, xmin, xmax = x_frame(self.X, plot_limits=plot_limits)
|
||||
m, lower, upper = self.predict(Xnew, slices=which_functions)
|
||||
gpplot(Xnew,m, lower, upper)
|
||||
pb.plot(self.X[which_data],self.likelihood.data[which_data],'kx',mew=1.5)
|
||||
ymin,ymax = self.likelihood.data.min()*1.2,self.likelihood.data.max()*1.2
|
||||
pb.xlim(xmin,xmax)
|
||||
pb.ylim(ymin,ymax)
|
||||
|
||||
if self.X.shape[1] == 1:
|
||||
Xnew, xmin, xmax = x_frame1D(self.X, plot_limits=plot_limits)
|
||||
m, lower, upper = self.predict(Xnew, slices=which_functions)
|
||||
gpplot(Xnew,m, lower, upper)
|
||||
pb.plot(self.X[which_data],self.likelihood.data[which_data],'kx',mew=1.5)
|
||||
ymin,ymax = self.likelihood.data.min()*1.2,self.likelihood.data.max()*1.2
|
||||
pb.xlim(xmin,xmax)
|
||||
pb.ylim(ymin,ymax)
|
||||
elif X.shape[1]==2:
|
||||
resolution = resolution or 50
|
||||
Xnew, xmin, xmax,xx,yy = x_frame2D(self.X, plot_limits=plot_limits)
|
||||
m,v = self.predict(Xnew, slices=which_functions)
|
||||
m = m.reshape(resolution,resolution)
|
||||
pb.contour(xx,yy,zz,vmin=zz.min(),vmax=zz.max(),cmap=pb.cm.jet)
|
||||
pb.scatter(Xorig[:,0],Xorig[:,1],40,Yorig,linewidth=0,cmap=pb.cm.jet,vmin=zz.min(),vmax=zz.max())
|
||||
pb.xlim(xmin[0],xmax[0])
|
||||
pb.ylim(xmin[1],xmax[1])
|
||||
else:
|
||||
raise NotImplementedError, "Cannot define a frame with more than two input dimensions"
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue