code: def gaussian_process_binary_classification_laplace(
      X_train, y_train, n_test=50
  ):
      import shogun as sg
  
      # convert training data into Shogun representation
      train_features = sg.create_features(X_train)
      train_labels = sg.create_labels(y_train)
  
      # generate all pairs in 2d range of testing data
      x1 = np.linspace(
          X_train[0, :].min() - 1, X_train[0, :].max() + 1, n_test
      )
      x2 = np.linspace(
          X_train[1, :].min() - 1, X_train[1, :].max() + 1, n_test
      )
      X_test = np.asarray(list(itertools.product(x1, x2))).T
  
      # convert testing features into Shogun representation
      test_features = sg.create_features(X_test)
  
      # create Gaussian kernel with width = 2.0
      kernel = sg.create_kernel("GaussianKernel", width=2.0)
  
      # create zero mean function
      mean = sg.gp_mean("ZeroMean")
  
      # you can easily switch between probit and logit likelihood models
      # by uncommenting/commenting the following lines:
  
      # create probit likelihood model
      # lik = ProbitLikelihood()
  
      # create logit likelihood model
      lik = sg.gp_likelihood("LogitLikelihood")
  
      # you can easily switch between Laplace and EP approximation by
      # uncommenting/commenting the following lines:
  
      # specify Laplace approximation inference method
      # inf = SingleLaplacianInferenceMethod(kernel, train_features, mean, train_labels, lik)
  
      # specify EP approximation inference method
      inf = sg.gp_inference(
          "MultiLaplaceInferenceMethod",
          kernel=kernel,
          features=train_features,
          mean_function=mean,
          labels=train_labels,
          likelihood_model=lik,
      )
      # create and train GP classifier, which uses Laplace approximation
      # gp = sg.machine('GaussianProcessClassification', inference_method=inf, labels=train_labels)
      gp = sg.gaussian_process(
          "GaussianProcessClassification", inference_method=inf
      )
      gp.train()
  
      # get probabilities p(y*=1|x*) for each testing feature x*
      p_test = gp.get_probabilities(test_features)
  
      # create figure
      plt.title(
          "Training examples, predictive probability and decision boundary"
      )
  
      # plot training data
      plt.plot(
          X_train[0, np.argwhere(y_train == 1)],
          X_train[1, np.argwhere(y_train == 1)],
          "ro",
      )
      plt.plot(
          X_train[0, np.argwhere(y_train == -1)],
          X_train[1, np.argwhere(y_train == -1)],
          "bo",
      )
  
      # plot decision boundary
      plt.contour(
          x1,
          x2,
          np.reshape(p_test, (n_test, n_test)),
          levels=[0.5],
          colors="black",
      )
  
      # plot probabilities
      plt.pcolor(x1, x2, np.reshape(p_test, (n_test, n_test)))
  
      # show color bar
      plt.colorbar()
  
      # show figure
      plt.show()
  
imports: import itertools
  import matplotlib.pyplot
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: gaussian_process_binary_classification_laplace(X_train, y_train, n_test) without return types