class_docstr: Test class for custom metric tests.
docstr: Test API with custom metrics.
docstr_tok: ["Test","API","with","custom","metrics","."]
code: def test_custom_metric_api_experiment(self):
      """Test API with custom metrics."""
      # register two different metrics from two files
      custom_metrics_file1 = other_dir / "custom_metrics.py"
      register_custom_metric(custom_metrics_file1, "f075_macro")
      custom_metrics_file2 = other_dir / "custom_metrics2.py"
      register_custom_metric(custom_metrics_file2, "f06_micro")
  
      # read in some train/test data
      train_file = other_dir / "examples_train.jsonlines"
      test_file = other_dir / "examples_test.jsonlines"
  
      train_fs = NDJReader.for_path(train_file).read()
      test_fs = NDJReader.for_path(test_file).read()
  
      # set up a learner to tune using one of the custom metrics
      # and evaluate it using the other one
      learner = Learner("LogisticRegression")
      _ = learner.train(
          train_fs, grid_objective="f075_macro", grid_search_folds=3
      )
      results = learner.evaluate(
          test_fs,
          grid_objective="f075_macro",
          output_metrics=["balanced_accuracy", "f06_micro"],
      )
      test_objective_value = results[-2]
      test_output_metrics_dict = results[-1]
      test_accuracy_value = test_output_metrics_dict[
          "balanced_accuracy"
      ]
      test_f06_micro_value = test_output_metrics_dict["f06_micro"]
  
      # check that the values are as expected
      self.assertAlmostEqual(test_objective_value, 0.9785, places=4)
      self.assertAlmostEqual(test_accuracy_value, 0.9792, places=4)
      self.assertAlmostEqual(test_f06_micro_value, 0.98, places=4)
  
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 15 for calling the TestCustomMetrics obj's underlying member method code with example usage: obj.test_custom_metric_api_experiment() without return types