class_docstr: Test class for custom metric tests.
docstr: Test API with custom probabilistic metric.
docstr_tok: ["Test","API","with","custom","probabilistic","metric","."]
code: def test_api_with_custom_prob_metric(self):
      """Test API with custom probabilistic metric."""
      # register a custom metric from our file that requires probabilities
      custom_metrics_file = other_dir / "custom_metrics.py"
      register_custom_metric(custom_metrics_file, "fake_prob_metric")
  
      # create some classification data
      train_fs, _ = make_classification_data(
          num_examples=1000, num_features=10, num_labels=2
      )
  
      # set up a learner to tune using this probabilistic metric
      # this should fail since LinearSVC doesn't support probabilities
      learner1 = Learner("LinearSVC")
      assert_raises_regex(
          AttributeError,
          r"has none of the following attributes: predict_proba",
          learner1.train,
          train_fs,
          grid_objective="fake_prob_metric",
          grid_search_folds=3,
      )
  
      # set up another learner with explicit probability support
      # this should work just fine with our custom metric
      learner2 = Learner("SVC", probability=True)
      grid_score, _ = learner2.train(
          train_fs,
          grid_objective="fake_prob_metric",
          grid_search_folds=3,
      )
      self.assertTrue(grid_score > 0.95)
  
imports: import json
  import sys
  import unittest
  from itertools import chain
  import numpy
  from numpy.testing import assert_array_almost_equal, assert_array_equal, assert_raises_regex
  from sklearn.metrics import fbeta_score
  import skll.metrics
  from skll.data import NDJReader
  from skll.experiments import run_configuration
  from skll.learner import Learner
  from skll.metrics import _CUSTOM_METRICS, register_custom_metric, use_score_func
  from skll.utils.testing import config_dir, fill_in_config_paths_for_single_file, make_classification_data, other_dir, output_dir, unlink
label_desc: Use image node_id 22 for calling the TestCustomMetrics obj's underlying member method code with example usage: obj.test_api_with_custom_prob_metric() without return types