class_docstr: Unit test class for testing the libsvm sklearn converter.
class_docstr_tok: ["Unit","test","class","for","testing","the","libsvm","sklearn","converter","."]
docstr: Test that the same predictions are made
docstr_tok: ["Test","that","the","same","predictions","are","made"]
code: def _test_evaluation(self, allow_slow):
      """
      Test that the same predictions are made
      """
      from svm import svm_parameter, svm_problem
      from svmutil import svm_predict, svm_train
  
      # Generate some smallish (poly kernels take too long on anything else) random data
      x, y = [], []
      for _ in range(50):
          cur_x1, cur_x2 = random.gauss(2, 3), random.gauss(-1, 2)
          x.append([cur_x1, cur_x2])
          y.append(1 + 2 * cur_x1 + 3 * cur_x2)
  
      input_names = ["x1", "x2"]
      df = pd.DataFrame(x, columns=input_names)
      prob = svm_problem(y, x)
  
      # Parameters
      base_param = "-s 3"  # model type is epsilon SVR
      non_kernel_parameters = [
          "",
          "-c 1.5 -p 0.5 -h 1",
          "-c 0.5 -p 0.5 -h 0",
      ]
      kernel_parameters = [
          "",
          "-t 2 -g 1.2",  # rbf kernel
          "-t 0",  # linear kernel
          "-t 1",
          "-t 1 -d 2",
          "-t 1 -g 0.75",
          "-t 1 -d 0 -g 0.9 -r 2",  # poly kernel
          "-t 3",
          "-t 3 -g 1.3",
          "-t 3 -r 0.8",
          "-t 3 -r 0.8 -g 0.5",  # sigmoid kernel
      ]
  
      for param1 in non_kernel_parameters:
          for param2 in kernel_parameters:
              param_str = " ".join([base_param, param1, param2])
              print(param_str)
              param = svm_parameter(param_str)
  
              model = svm_train(prob, param)
              (df["target"], _, _) = svm_predict(y, x, model)
  
              spec = libsvm.convert(
                  model, input_names=input_names, target_name="target"
              )
  
              if _is_macos() and _macos_version() >= (10, 13):
                  metrics = evaluate_regressor(spec, df)
                  self.assertAlmostEqual(metrics["max_error"], 0)
  
              if not allow_slow:
                  break
  
          if not allow_slow:
              break
  
imports: import random
  import tempfile
  import unittest
  import numpy
  import pandas
  import pytest
  from coremltools._deps import _HAS_LIBSVM, _HAS_SKLEARN, MSG_LIBSVM_NOT_FOUND, MSG_SKLEARN_NOT_FOUND
  from coremltools.models.utils import _is_macos, _macos_version, evaluate_regressor
label_desc: Use image node_id 7 for calling the EpsilonSVRLibSVMTest obj's underlying member method code with example usage: obj._test_evaluation(allow_slow) without return types