<s> import numpy as np <EOL> from . import plotting_library as pl <EOL> from . plot_util import get_x_y_var , get_free_dims , get_which_data_ycols , get_which_data_rows , update_not_existing_kwargs , helper_predict_with_model <EOL> def plot_data ( self , which_data_rows = '<STR_LIT:all>' , <EOL> which_data_ycols = '<STR_LIT:all>' , visible_dims = None , <EOL> projection = '<STR_LIT>' , label = None , ** plot_kwargs ) : <EOL> """<STR_LIT>""" <EOL> canvas , plot_kwargs = pl ( ) . new_canvas ( projection = projection , ** plot_kwargs ) <EOL> plots = _plot_data ( self , canvas , which_data_rows , which_data_ycols , visible_dims , projection , label , ** plot_kwargs ) <EOL> return pl ( ) . add_to_canvas ( canvas , plots ) <EOL> def _plot_data ( self , canvas , which_data_rows = '<STR_LIT:all>' , <EOL> which_data_ycols = '<STR_LIT:all>' , visible_dims = None , <EOL> projection = '<STR_LIT>' , label = None , ** plot_kwargs ) : <EOL> ycols = get_which_data_ycols ( self , which_data_ycols ) <EOL> rows = get_which_data_rows ( self , which_data_rows ) <EOL> X , _ , Y = get_x_y_var ( self ) <EOL> free_dims = get_free_dims ( self , visible_dims , None ) <EOL> plots = { } <EOL> plots [ '<STR_LIT>' ] = [ ] <EOL> if len ( free_dims ) == <NUM_LIT:1> : <EOL> for d in ycols : <EOL> update_not_existing_kwargs ( plot_kwargs , pl ( ) . defaults . data_1d ) <EOL> plots [ '<STR_LIT>' ] . append ( pl ( ) . scatter ( canvas , X [ rows , free_dims ] , Y [ rows , d ] , label = label , ** plot_kwargs ) ) <EOL> elif len ( free_dims ) == <NUM_LIT:2> : <EOL> if projection == '<STR_LIT>' : <EOL> for d in ycols : <EOL> update_not_existing_kwargs ( plot_kwargs , pl ( ) . defaults . data_2d ) <EOL> plots [ '<STR_LIT>' ] . append ( pl ( ) . scatter ( canvas , X [ rows , free_dims [ <NUM_LIT:0> ] ] , X [ rows , free_dims [ <NUM_LIT:1> ] ] , <EOL> color = Y [ rows , d ] , label = label , ** plot_kwargs ) ) <EOL> else : <EOL> for d in ycols : <EOL> update_not_existing_kwargs ( plot_kwargs , pl ( ) . defaults . data_2d ) <EOL> plots [ '<STR_LIT>' ] . append ( pl ( ) . scatter ( canvas , X [ rows , free_dims [ <NUM_LIT:0> ] ] , X [ rows , free_dims [ <NUM_LIT:1> ] ] , <EOL> Z = Y [ rows , d ] , color = Y [ rows , d ] , label = label , ** plot_kwargs ) ) <EOL> elif len ( free_dims ) == <NUM_LIT:0> : <EOL> pass <EOL> else : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> return plots <EOL> def plot_data_error ( self , which_data_rows = '<STR_LIT:all>' , <EOL> which_data_ycols = '<STR_LIT:all>' , visible_dims = None , <EOL> projection = '<STR_LIT>' , label = None , ** error_kwargs ) : <EOL> """<STR_LIT>""" <EOL> canvas , error_kwargs = pl ( ) . new_canvas ( projection = projection , ** error_kwargs ) <EOL> plots = _plot_data_error ( self , canvas , which_data_rows , which_data_ycols , visible_dims , projection , label , ** error_kwargs ) <EOL> return pl ( ) . add_to_canvas ( canvas , plots ) <EOL> def _plot_data_error ( self , canvas , which_data_rows = '<STR_LIT:all>' , <EOL> which_data_ycols = '<STR_LIT:all>' , visible_dims = None , <EOL> projection = '<STR_LIT>' , label = None , ** error_kwargs ) : <EOL> ycols = get_which_data_ycols ( self , which_data_ycols ) <EOL> rows = get_which_data_rows ( self , which_data_rows ) <EOL> X , X_variance , Y = get_x_y_var ( self ) <EOL> free_dims = get_free_dims ( self , visible_dims , None ) <EOL> plots = { } <EOL> if X_variance is not None : <EOL> plots [ '<STR_LIT>' ] = [ ] <EOL> if len ( free_dims ) == <NUM_LIT:1> : <EOL> for d in ycols : <EOL> update_not_existing_kwargs ( error_kwargs , pl ( ) . defaults . xerrorbar ) <EOL> plots [ '<STR_LIT>' ] . append ( pl ( ) . xerrorbar ( canvas , X [ rows , free_dims ] . flatten ( ) , Y [ rows , d ] . flatten ( ) , <EOL> <NUM_LIT:2> * np . sqrt ( X_variance [ rows , free_dims ] . flatten ( ) ) , label = label , <EOL> ** error_kwargs ) ) <EOL> elif len ( free_dims ) == <NUM_LIT:2> : <EOL> update_not_existing_kwargs ( error_kwargs , pl ( ) . defaults . xerrorbar ) <EOL> plots [ '<STR_LIT>' ] . append ( pl ( ) . xerrorbar ( canvas , X [ rows , free_dims [ <NUM_LIT:0> ] ] . flatten ( ) , X [ rows , free_dims [ <NUM_LIT:1> ] ] . flatten ( ) , <EOL> <NUM_LIT:2> * np . sqrt ( X_variance [ rows , free_dims [ <NUM_LIT:0> ] ] . flatten ( ) ) , label = label , <EOL> ** error_kwargs ) ) <EOL> plots [ '<STR_LIT>' ] . append ( pl ( ) . yerrorbar ( canvas , X [ rows , free_dims [ <NUM_LIT:0> ] ] . flatten ( ) , X [ rows , free_dims [ <NUM_LIT:1> ] ] . flatten ( ) , <EOL> <NUM_LIT:2> * np . sqrt ( X_variance [ rows , free_dims [ <NUM_LIT:1> ] ] . flatten ( ) ) , label = label , <EOL> ** error_kwargs ) ) <EOL> elif len ( free_dims ) == <NUM_LIT:0> : <EOL> pass <EOL> else : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> return plots <EOL> def plot_inducing ( self , visible_dims = None , projection = '<STR_LIT>' , label = '<STR_LIT>' , legend = True , ** plot_kwargs ) : <EOL> """<STR_LIT>""" <EOL> canvas , kwargs = pl ( ) . new_canvas ( projection = projection , ** plot_kwargs ) <EOL> plots = _plot_inducing ( self , canvas , visible_dims , projection , label , ** kwargs ) <EOL> return pl ( ) . add_to_canvas ( canvas , plots , legend = legend ) <EOL> def _plot_inducing ( self , canvas , visible_dims , projection , label , ** plot_kwargs ) : <EOL> if visible_dims is None : <EOL> sig_dims = self . get_most_significant_input_dimensions ( ) <EOL> visible_dims = [ i for i in sig_dims if i is not None ] <EOL> free_dims = get_free_dims ( self , visible_dims , None ) <EOL> Z = self . Z . values <EOL> plots = { } <EOL> if len ( free_dims ) == <NUM_LIT:1> : <EOL> update_not_existing_kwargs ( plot_kwargs , pl ( ) . defaults . inducing_1d ) <EOL> plots [ '<STR_LIT>' ] = pl ( ) . plot_axis_lines ( canvas , Z [ : , free_dims ] , label = label , ** plot_kwargs ) <EOL> elif len ( free_dims ) == <NUM_LIT:2> and projection == '<STR_LIT>' : <EOL> update_not_existing_kwargs ( plot_kwargs , pl ( ) . defaults . inducing_3d ) <EOL> plots [ '<STR_LIT>' ] = pl ( ) . plot_axis_lines ( canvas , Z [ : , free_dims ] , label = label , ** plot_kwargs ) <EOL> elif len ( free_dims ) == <NUM_LIT:2> : <EOL> update_not_existing_kwargs ( plot_kwargs , pl ( ) . defaults . inducing_2d ) <EOL> plots [ '<STR_LIT>' ] = pl ( ) . scatter ( canvas , Z [ : , free_dims [ <NUM_LIT:0> ] ] , Z [ : , free_dims [ <NUM_LIT:1> ] ] , <EOL> label = label , ** plot_kwargs ) <EOL> elif len ( free_dims ) == <NUM_LIT:0> : <EOL> pass <EOL> else : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> return plots <EOL> def plot_errorbars_trainset ( self , which_data_rows = '<STR_LIT:all>' , <EOL> which_data_ycols = '<STR_LIT:all>' , fixed_inputs = None , <EOL> plot_raw = False , apply_link = False , label = None , projection = '<STR_LIT>' , <EOL> predict_kw = None , ** plot_kwargs ) : <EOL> """<STR_LIT>""" <EOL> canvas , kwargs = pl ( ) . new_canvas ( projection = projection , ** plot_kwargs ) <EOL> plots = _plot_errorbars_trainset ( self , canvas , which_data_rows , which_data_ycols , <EOL> fixed_inputs , plot_raw , apply_link , label , projection , predict_kw , ** kwargs ) <EOL> return pl ( ) . add_to_canvas ( canvas , plots ) <EOL> def _plot_errorbars_trainset ( self , canvas , <EOL> which_data_rows = '<STR_LIT:all>' , which_data_ycols = '<STR_LIT:all>' , <EOL> fixed_inputs = None , <EOL> plot_raw = False , apply_link = False , <EOL> label = None , projection = '<STR_LIT>' , predict_kw = None , ** plot_kwargs ) : <EOL> ycols = get_which_data_ycols ( self , which_data_ycols ) <EOL> rows = get_which_data_rows ( self , which_data_rows ) <EOL> X , _ , Y = get_x_y_var ( self ) <EOL> if fixed_inputs is None : <EOL> fixed_inputs = [ ] <EOL> free_dims = get_free_dims ( self , None , fixed_inputs ) <EOL> Xgrid = X . copy ( ) <EOL> for i , v in fixed_inputs : <EOL> Xgrid [ : , i ] = v <EOL> plots = [ ] <EOL> if len ( free_dims ) <= <NUM_LIT:2> and projection == '<STR_LIT>' : <EOL> update_not_existing_kwargs ( plot_kwargs , pl ( ) . defaults . yerrorbar ) <EOL> if predict_kw is None : <EOL> predict_kw = { } <EOL> if '<STR_LIT>' not in predict_kw : <EOL> predict_kw [ '<STR_LIT>' ] = self . Y_metadata or { } <EOL> mu , percs , _ = helper_predict_with_model ( self , Xgrid , plot_raw , <EOL> apply_link , ( <NUM_LIT> , <NUM_LIT> ) , <EOL> ycols , predict_kw ) <EOL> if len ( free_dims ) == <NUM_LIT:1> : <EOL> for d in ycols : <EOL> plots . append ( pl ( ) . yerrorbar ( canvas , X [ rows , free_dims [ <NUM_LIT:0> ] ] , mu [ rows , d ] , <EOL> np . vstack ( [ mu [ rows , d ] - percs [ <NUM_LIT:0> ] [ rows , d ] , percs [ <NUM_LIT:1> ] [ rows , d ] - mu [ rows , d ] ] ) , <EOL> label = label , <EOL> ** plot_kwargs ) ) <EOL> else : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> return dict ( yerrorbars = plots ) </s>
