code: def snelsonDemo():
      from IPython import embed
      from matplotlib import pyplot as plt
  
      Xtrain, Ytrain, Xtest, Ytest = getTrainingTestData()
  
      # run exact inference on training data.
      exact_model = getRegressionModel(Xtrain, Ytrain)
      opt = gpflow.train.ScipyOptimizer()
      opt.minimize(exact_model, maxiter=reduce_in_tests(2000000))
  
      figA, axes = plt.subplots(1, 1)
      inds = np.argsort(Xtrain.flatten())
      axes.plot(Xtrain[inds, :], Ytrain[inds, :], "ro")
      plotPredictions(axes, exact_model, "g", None)
  
      figB, axes = plt.subplots(3, 2)
  
      # run sparse model on training data initialized from exact optimal solution.
      VFEmodel, VFEcb = trainSparseModel(
          Xtrain, Ytrain, exact_model, False, Xtest, Ytest
      )
      FITCmodel, FITCcb = trainSparseModel(
          Xtrain, Ytrain, exact_model, True, Xtest, Ytest
      )
  
      print("Exact model parameters \n")
      printModelParameters(exact_model)
      print("Sparse model parameters for VFE optimization \n")
      printModelParameters(VFEmodel)
      print("Sparse model parameters for FITC optimization \n")
      printModelParameters(FITCmodel)
  
      VFEiters = FITCcb.n_iters
      VFElog_likelihoods = stretch(len(VFEiters), VFEcb.log_likelihoods)
      VFEhold_out_likelihood = stretch(
          len(VFEiters), VFEcb.hold_out_likelihood
      )
  
      plotComparisonFigure(
          Xtrain,
          VFEmodel,
          exact_model,
          axes[0, 0],
          axes[1, 0],
          axes[2, 0],
          VFEiters,
          VFElog_likelihoods,
          VFEhold_out_likelihood,
          "VFE",
      )
      plotComparisonFigure(
          Xtrain,
          FITCmodel,
          exact_model,
          axes[0, 1],
          axes[1, 1],
          axes[2, 1],
          FITCcb.n_iters,
          FITCcb.log_likelihoods,
          FITCcb.hold_out_likelihood,
          "FITC",
      )
  
      axes[0, 0].set_title(
          "VFE", loc="center", fontdict={"fontsize": 22}
      )
      axes[0, 1].set_title(
          "FITC", loc="center", fontdict={"fontsize": 22}
      )
  
      embed()
  
file_path: GPflow/doc/sphinx/notebooks/theory/FITCvsVFE.py
imports: import numpy
  import tensorflow
  import gpflow
  from gpflow.ci_utils import reduce_in_tests
label_desc: Use image node_id 13 for calling a global function with example usage: snelsonDemo() without return types