<s> import numpy as np <EOL> from . import plotting_library as pl <EOL> from . plot_util import helper_for_plot_data , update_not_existing_kwargs , helper_predict_with_model , get_which_data_ycols , get_x_y_var <EOL> from . data_plots import _plot_data , _plot_inducing , _plot_data_error <EOL> def plot_mean ( self , plot_limits = None , fixed_inputs = None , <EOL> resolution = None , plot_raw = False , <EOL> apply_link = False , visible_dims = None , <EOL> which_data_ycols = '<STR_LIT:all>' , <EOL> levels = <NUM_LIT:20> , projection = '<STR_LIT>' , <EOL> label = '<STR_LIT>' , <EOL> predict_kw = None , <EOL> ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> canvas , kwargs = pl ( ) . new_canvas ( projection = projection , ** kwargs ) <EOL> X = get_x_y_var ( self ) [ <NUM_LIT:0> ] <EOL> helper_data = helper_for_plot_data ( self , X , plot_limits , visible_dims , fixed_inputs , resolution ) <EOL> helper_prediction = helper_predict_with_model ( self , helper_data [ <NUM_LIT:2> ] , plot_raw , <EOL> apply_link , None , <EOL> get_which_data_ycols ( self , which_data_ycols ) , <EOL> predict_kw ) <EOL> plots = _plot_mean ( self , canvas , helper_data , helper_prediction , <EOL> levels , projection , label , ** kwargs ) <EOL> return pl ( ) . add_to_canvas ( canvas , plots ) <EOL> def _plot_mean ( self , canvas , helper_data , helper_prediction , <EOL> levels = <NUM_LIT:20> , projection = '<STR_LIT>' , label = None , <EOL> ** kwargs ) : <EOL> _ , free_dims , Xgrid , x , y , _ , _ , resolution = helper_data <EOL> if len ( free_dims ) <= <NUM_LIT:2> : <EOL> mu , _ , _ = helper_prediction <EOL> if len ( free_dims ) == <NUM_LIT:1> : <EOL> update_not_existing_kwargs ( kwargs , pl ( ) . defaults . meanplot_1d ) <EOL> plots = dict ( gpmean = [ pl ( ) . plot ( canvas , Xgrid [ : , free_dims ] , mu , label = label , ** kwargs ) ] ) <EOL> else : <EOL> if projection == '<STR_LIT>' : <EOL> update_not_existing_kwargs ( kwargs , pl ( ) . defaults . meanplot_2d ) <EOL> plots = dict ( gpmean = [ pl ( ) . contour ( canvas , x [ : , <NUM_LIT:0> ] , y [ <NUM_LIT:0> , : ] , <EOL> mu . reshape ( resolution , resolution ) . T , <EOL> levels = levels , label = label , ** kwargs ) ] ) <EOL> elif projection == '<STR_LIT>' : <EOL> update_not_existing_kwargs ( kwargs , pl ( ) . defaults . meanplot_3d ) <EOL> plots = dict ( gpmean = [ pl ( ) . surface ( canvas , x , y , <EOL> mu . reshape ( resolution , resolution ) , <EOL> label = label , <EOL> ** kwargs ) ] ) <EOL> elif len ( free_dims ) == <NUM_LIT:0> : <EOL> pass <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> return plots <EOL> def plot_confidence ( self , lower = <NUM_LIT> , upper = <NUM_LIT> , plot_limits = None , fixed_inputs = None , <EOL> resolution = None , plot_raw = False , <EOL> apply_link = False , visible_dims = None , <EOL> which_data_ycols = '<STR_LIT:all>' , label = '<STR_LIT>' , <EOL> predict_kw = None , <EOL> ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> canvas , kwargs = pl ( ) . new_canvas ( ** kwargs ) <EOL> ycols = get_which_data_ycols ( self , which_data_ycols ) <EOL> X = get_x_y_var ( self ) [ <NUM_LIT:0> ] <EOL> helper_data = helper_for_plot_data ( self , X , plot_limits , visible_dims , fixed_inputs , resolution ) <EOL> helper_prediction = helper_predict_with_model ( self , helper_data [ <NUM_LIT:2> ] , plot_raw , apply_link , <EOL> ( lower , upper ) , <EOL> ycols , predict_kw ) <EOL> plots = _plot_confidence ( self , canvas , helper_data , helper_prediction , label , ** kwargs ) <EOL> return pl ( ) . add_to_canvas ( canvas , plots , legend = label is not None ) <EOL> def _plot_confidence ( self , canvas , helper_data , helper_prediction , label , ** kwargs ) : <EOL> _ , free_dims , Xgrid , _ , _ , _ , _ , _ = helper_data <EOL> update_not_existing_kwargs ( kwargs , pl ( ) . defaults . confidence_interval ) <EOL> if len ( free_dims ) <= <NUM_LIT:1> : <EOL> if len ( free_dims ) == <NUM_LIT:1> : <EOL> percs = helper_prediction [ <NUM_LIT:1> ] <EOL> fills = [ ] <EOL> for d in range ( helper_prediction [ <NUM_LIT:0> ] . shape [ <NUM_LIT:1> ] ) : <EOL> fills . append ( pl ( ) . fill_between ( canvas , Xgrid [ : , free_dims [ <NUM_LIT:0> ] ] , percs [ <NUM_LIT:0> ] [ : , d ] , percs [ <NUM_LIT:1> ] [ : , d ] , label = label , ** kwargs ) ) <EOL> return dict ( gpconfidence = fills ) <EOL> else : <EOL> pass <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> def plot_samples ( self , plot_limits = None , fixed_inputs = None , <EOL> resolution = None , plot_raw = True , <EOL> apply_link = False , visible_dims = None , <EOL> which_data_ycols = '<STR_LIT:all>' , <EOL> samples = <NUM_LIT:3> , projection = '<STR_LIT>' , label = '<STR_LIT>' , <EOL> predict_kw = None , <EOL> ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> canvas , kwargs = pl ( ) . new_canvas ( projection = projection , ** kwargs ) <EOL> ycols = get_which_data_ycols ( self , which_data_ycols ) <EOL> X = get_x_y_var ( self ) [ <NUM_LIT:0> ] <EOL> helper_data = helper_for_plot_data ( self , X , plot_limits , visible_dims , fixed_inputs , resolution ) <EOL> helper_prediction = helper_predict_with_model ( self , helper_data [ <NUM_LIT:2> ] , plot_raw , apply_link , <EOL> None , <EOL> ycols , predict_kw , samples ) <EOL> plots = _plot_samples ( self , canvas , helper_data , helper_prediction , <EOL> projection , label , ** kwargs ) <EOL> return pl ( ) . add_to_canvas ( canvas , plots ) <EOL> def _plot_samples ( self , canvas , helper_data , helper_prediction , projection , <EOL> label , ** kwargs ) : <EOL> _ , free_dims , Xgrid , x , y , _ , _ , resolution = helper_data <EOL> samples = helper_prediction [ <NUM_LIT:2> ] <EOL> if len ( free_dims ) <= <NUM_LIT:2> : <EOL> if len ( free_dims ) == <NUM_LIT:1> : <EOL> update_not_existing_kwargs ( kwargs , pl ( ) . defaults . samples_1d ) <EOL> plots = [ pl ( ) . plot ( canvas , Xgrid [ : , free_dims ] , samples [ : , s ] , label = label if s == <NUM_LIT:0> else None , ** kwargs ) for s in range ( samples . shape [ - <NUM_LIT:1> ] ) ] <EOL> elif len ( free_dims ) == <NUM_LIT:2> and projection == '<STR_LIT>' : <EOL> update_not_existing_kwargs ( kwargs , pl ( ) . defaults . samples_3d ) <EOL> plots = [ pl ( ) . surface ( canvas , x , y , samples [ : , s ] . reshape ( resolution , resolution ) , ** kwargs ) for s in range ( samples . shape [ - <NUM_LIT:1> ] ) ] <EOL> else : <EOL> pass <EOL> return dict ( gpmean = plots ) <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> def plot_density ( self , plot_limits = None , fixed_inputs = None , <EOL> resolution = None , plot_raw = False , <EOL> apply_link = False , visible_dims = None , <EOL> which_data_ycols = '<STR_LIT:all>' , <EOL> levels = <NUM_LIT> , label = '<STR_LIT>' , <EOL> predict_kw = None , <EOL> ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> canvas , kwargs = pl ( ) . new_canvas ( ** kwargs ) <EOL> X = get_x_y_var ( self ) [ <NUM_LIT:0> ] <EOL> helper_data = helper_for_plot_data ( self , X , plot_limits , visible_dims , fixed_inputs , resolution ) <EOL> helper_prediction = helper_predict_with_model ( self , helper_data [ <NUM_LIT:2> ] , plot_raw , <EOL> apply_link , np . linspace ( <NUM_LIT> , <NUM_LIT> , levels * <NUM_LIT:2> ) , <EOL> get_which_data_ycols ( self , which_data_ycols ) , <EOL> predict_kw ) <EOL> plots = _plot_density ( self , canvas , helper_data , helper_prediction , label , ** kwargs ) <EOL> return pl ( ) . add_to_canvas ( canvas , plots ) <EOL> def _plot_density ( self , canvas , helper_data , helper_prediction , label , ** kwargs ) : <EOL> _ , free_dims , Xgrid , _ , _ , _ , _ , _ = helper_data <EOL> mu , percs , _ = helper_prediction <EOL> update_not_existing_kwargs ( kwargs , pl ( ) . defaults . density ) <EOL> if len ( free_dims ) <= <NUM_LIT:1> : <EOL> if len ( free_dims ) == <NUM_LIT:1> : <EOL> fills = [ ] <EOL> for d in range ( mu . shape [ <NUM_LIT:1> ] ) : <EOL> fills . append ( pl ( ) . fill_gradient ( canvas , Xgrid [ : , free_dims [ <NUM_LIT:0> ] ] , [ p [ : , d ] for p in percs ] , label = label , ** kwargs ) ) <EOL> return dict ( gpdensity = fills ) <EOL> else : <EOL> pass <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> def plot ( self , plot_limits = None , fixed_inputs = None , <EOL> resolution = None , <EOL> plot_raw = False , apply_link = False , <EOL> which_data_ycols = '<STR_LIT:all>' , which_data_rows = '<STR_LIT:all>' , <EOL> visible_dims = None , <EOL> levels = <NUM_LIT:20> , samples = <NUM_LIT:0> , samples_likelihood = <NUM_LIT:0> , lower = <NUM_LIT> , upper = <NUM_LIT> , <EOL> plot_data = True , plot_inducing = True , plot_density = False , <EOL> predict_kw = None , projection = '<STR_LIT>' , legend = True , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> X = get_x_y_var ( self ) [ <NUM_LIT:0> ] <EOL> helper_data = helper_for_plot_data ( self , X , plot_limits , visible_dims , fixed_inputs , resolution ) <EOL> xmin , xmax = helper_data [ <NUM_LIT:5> : <NUM_LIT:7> ] <EOL> free_dims = helper_data [ <NUM_LIT:1> ] <EOL> if not '<STR_LIT>' in kwargs : <EOL> kwargs [ '<STR_LIT>' ] = ( xmin [ <NUM_LIT:0> ] , xmax [ <NUM_LIT:0> ] ) <EOL> if not '<STR_LIT>' in kwargs and len ( free_dims ) == <NUM_LIT:2> : <EOL> kwargs [ '<STR_LIT>' ] = ( xmin [ <NUM_LIT:1> ] , xmax [ <NUM_LIT:1> ] ) <EOL> canvas , _ = pl ( ) . new_canvas ( projection = projection , ** kwargs ) <EOL> helper_prediction = helper_predict_with_model ( self , helper_data [ <NUM_LIT:2> ] , plot_raw , <EOL> apply_link , np . linspace ( <NUM_LIT> , <NUM_LIT> , levels * <NUM_LIT:2> ) if plot_density else ( lower , upper ) , <EOL> get_which_data_ycols ( self , which_data_ycols ) , <EOL> predict_kw , samples ) <EOL> if plot_raw and not apply_link : <EOL> plot_data = False <EOL> plots = { } <EOL> if hasattr ( self , '<STR_LIT>' ) and plot_inducing : <EOL> plots . update ( _plot_inducing ( self , canvas , visible_dims , projection , '<STR_LIT>' ) ) <EOL> if plot_data : <EOL> plots . update ( _plot_data ( self , canvas , which_data_rows , which_data_ycols , free_dims , projection , "<STR_LIT>" ) ) <EOL> plots . update ( _plot_data_error ( self , canvas , which_data_rows , which_data_ycols , free_dims , projection , "<STR_LIT>" ) ) <EOL> plots . update ( _plot ( self , canvas , plots , helper_data , helper_prediction , levels , plot_inducing , plot_density , projection ) ) <EOL> if plot_raw and ( samples_likelihood > <NUM_LIT:0> ) : <EOL> helper_prediction = helper_predict_with_model ( self , helper_data [ <NUM_LIT:2> ] , False , <EOL> apply_link , None , <EOL> get_which_data_ycols ( self , which_data_ycols ) , <EOL> predict_kw , samples_likelihood ) <EOL> plots . update ( _plot_samples ( canvas , helper_data , helper_prediction , projection , "<STR_LIT>" ) ) <EOL> return pl ( ) . add_to_canvas ( canvas , plots , legend = legend ) <EOL> def plot_f ( self , plot_limits = None , fixed_inputs = None , <EOL> resolution = None , <EOL> apply_link = False , <EOL> which_data_ycols = '<STR_LIT:all>' , which_data_rows = '<STR_LIT:all>' , <EOL> visible_dims = None , <EOL> levels = <NUM_LIT:20> , samples = <NUM_LIT:0> , lower = <NUM_LIT> , upper = <NUM_LIT> , <EOL> plot_density = False , <EOL> plot_data = True , plot_inducing = True , <EOL> projection = '<STR_LIT>' , legend = True , <EOL> predict_kw = None , <EOL> ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return plot ( self , plot_limits , fixed_inputs , resolution , True , <EOL> apply_link , which_data_ycols , which_data_rows , <EOL> visible_dims , levels , samples , <NUM_LIT:0> , <EOL> lower , upper , plot_data , plot_inducing , <EOL> plot_density , predict_kw , projection , legend , ** kwargs ) <EOL> def _plot ( self , canvas , plots , helper_data , helper_prediction , levels , plot_inducing = True , plot_density = False , projection = '<STR_LIT>' ) : <EOL> plots . update ( _plot_mean ( self , canvas , helper_data , helper_prediction , levels , projection , '<STR_LIT>' ) ) <EOL> try : <EOL> if projection == '<STR_LIT>' : <EOL> if not plot_density : <EOL> plots . update ( _plot_confidence ( self , canvas , helper_data , helper_prediction , "<STR_LIT>" ) ) <EOL> else : <EOL> plots . update ( _plot_density ( self , canvas , helper_data , helper_prediction , "<STR_LIT>" ) ) <EOL> except RuntimeError : <EOL> pass <EOL> if helper_prediction [ <NUM_LIT:2> ] is not None : <EOL> plots . update ( _plot_samples ( self , canvas , helper_data , helper_prediction , projection , "<STR_LIT>" ) ) <EOL> return plots </s>
