class_docstr: Test class for custom metric tests.
docstr: Test API with metric defined in a file named kappa.
docstr_tok: ["Test","API","with","metric","defined","in","a","file","named","kappa","."]
code: def test_custom_metric_api_experiment_with_kappa_filename(self):
      """Test API with metric defined in a file named kappa."""
      # register a dummy metric that just returns 1 from
      # a file called 'kappa.py'
      custom_metrics_file = other_dir / "kappa.py"
      register_custom_metric(custom_metrics_file, "dummy_metric")
  
      # 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 our usual kappa metric
      # and evaluate it using the dummy metric we loaded
      # this should work as there should be no confict between
      # the two "kappa" names
      learner = Learner("LogisticRegression")
      _ = learner.train(
          train_fs,
          grid_objective="unweighted_kappa",
          grid_search_folds=3,
      )
      results = learner.evaluate(
          test_fs,
          grid_objective="unweighted_kappa",
          output_metrics=["balanced_accuracy", "dummy_metric"],
      )
      test_objective_value = results[-2]
      test_output_metrics_dict = results[-1]
      test_accuracy_value = test_output_metrics_dict[
          "balanced_accuracy"
      ]
      test_dummy_metric_value = test_output_metrics_dict["dummy_metric"]
  
      # check that the values are as expected
      self.assertAlmostEqual(test_objective_value, 0.9699, places=4)
      self.assertAlmostEqual(test_accuracy_value, 0.9792, places=4)
      self.assertEqual(test_dummy_metric_value, 1.0)
  
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 17 for calling the TestCustomMetrics obj's underlying member method code with example usage: obj.test_custom_metric_api_experiment_with_kappa_filename() without return types