class_docstr: Defing unit tests for CartesianProduct GPs. 
class_docstr_tok: ["Defing","unit","tests","for","CartesianProduct","GPs","."]
docstr: Tests fitting and creation. 
docstr_tok: ["Tests","fitting","and","creation","."]
code: def test_gp_fitting_and_creation(self):
      """Tests fitting and creation."""
      self.report(
          "Testing fitting Cartesian Product GP. Probabilistic test, might fail."
      )
      num_successes = 0
      for idx, dataset in enumerate(self.cpgp_datasets):
          fit_start_time = time()
          fitted_gp, cp_domain = fit_cpgp_with_dataset(
              dataset, cpgp.CPGPFitter
          )
          fit_end_time = time()
          fit_time = fit_end_time - fit_start_time
          lml = fitted_gp.compute_log_marginal_likelihood()
          gp_preds, _ = fitted_gp.eval(
              dataset.X_test, uncert_form="none"
          )
          test_succ, test_str = self._test_prediction(
              gp_preds, dataset.Y_test, dataset.Y_train
          )
          self.report(
              "[%d/%d] Fitted GP: lml=%0.4f, GP=%s, time_taken=%0.4fs"
              % (
                  idx + 1,
                  len(self.cpgp_datasets),
                  lml,
                  fitted_gp,
                  fit_time,
              ),
              "test_result",
          )
          self.report("   Test result: %s." % (test_str), "test_result")
          self.report("   Domain=%s." % (cp_domain), "test_result")
          num_successes += test_succ
      success_frac = num_successes / float(self.num_datasets)
      self.report(
          "Num successes = %d/%d (%0.4f).\n"
          % (num_successes, self.num_datasets, success_frac),
          "test_result",
      )
      assert success_frac > 0.5
  
imports: from argparse import Namespace
  import numpy
  import os
  from time import time
  from ..exd.cp_domain_utils import load_cp_domain_from_config_file, get_processed_func_from_raw_func_for_cp_domain, get_processed_func_from_raw_func_via_config, load_config_file, sample_from_config_space
  from .None import cartesian_product_gp
  from ..test_data.park1_3.park1_3 import park1_3
  from ..test_data.park1_3.park1_3_mf import park1_3_mf
  from ..test_data.park2_4.park2_4 import park2_4
  from ..test_data.park2_4.park2_4_mf import park2_4_mf
  from ..utils.base_test_class import BaseTestClass, execute_tests
  from ..utils.general_utils import map_to_bounds, get_idxs_from_list_of_lists
label_desc: Use image node_id 3 for calling the CPGPTestCaseDefinitions obj's underlying member method code with example usage: obj.test_gp_fitting_and_creation() without return types