class_docstr: Test class for output tests.
code: def check_summary_score(
      self, use_feature_hashing, use_additional_metrics
  ):  # noqa: C901
      # Test to validate summary file scores
      self.make_summary_data()
  
      if use_feature_hashing:
          cfgfile = (
              "test_summary_feature_hasher_with_metrics.template.cfg"
              if use_additional_metrics
              else "test_summary_feature_hasher.template.cfg"
          )
          outprefix = (
              "test_summary_feature_hasher_with_metrics_test_summary"
              if use_additional_metrics
              else "test_summary_feature_hasher_test_summary"
          )
          summprefix = (
              "test_summary_feature_hasher_with_metrics"
              if use_additional_metrics
              else "test_summary_feature_hasher"
          )
      else:
          cfgfile = (
              "test_summary_with_metrics.template.cfg"
              if use_additional_metrics
              else "test_summary.template.cfg"
          )
          outprefix = (
              "test_summary_with_metrics_test_summary"
              if use_additional_metrics
              else "test_summary_test_summary"
          )
          summprefix = (
              "test_summary_with_metrics"
              if use_additional_metrics
              else "test_summary"
          )
  
      config_template_path = config_dir / cfgfile
      config_path = fill_in_config_paths(config_template_path)
  
      run_configuration(config_path, quiet=True, local=True)
  
      with open(
          output_dir / f"{outprefix}_LogisticRegression.results.json"
      ) as f:
          outd = json.loads(f.read())
          logistic_result_score = outd[0]["score"]
          if use_additional_metrics:
              results_metrics_dict = outd[0]["additional_scores"]
              logistic_result_additional_metric1 = results_metrics_dict[
                  "unweighted_kappa"
              ]
              logistic_result_additional_metric2 = results_metrics_dict[
                  "f1_score_micro"
              ]
  
      with open(output_dir / f"{outprefix}_SVC.results.json") as f:
          outd = json.loads(f.read())
          svm_result_score = outd[0]["score"]
          if use_additional_metrics:
              results_metrics_dict = outd[0]["additional_scores"]
              svm_result_additional_metric1 = results_metrics_dict[
                  "unweighted_kappa"
              ]
              svm_result_additional_metric2 = results_metrics_dict[
                  "f1_score_micro"
              ]
  
      # note that Naive Bayes doesn't work with feature hashing
      if not use_feature_hashing:
          with open(
              output_dir / f"{outprefix}_MultinomialNB.results.json"
          ) as f:
              outd = json.loads(f.read())
              naivebayes_result_score = outd[0]["score"]
              if use_additional_metrics:
                  results_metrics_dict = outd[0]["additional_scores"]
                  nb_result_additional_metric1 = results_metrics_dict[
                      "unweighted_kappa"
                  ]
                  nb_result_additional_metric2 = results_metrics_dict[
                      "f1_score_micro"
                  ]
  
      with open(output_dir / f"{summprefix}_summary.tsv") as f:
          reader = csv.DictReader(f, dialect="excel-tab")
  
          for row in reader:
              # the learner results dictionaries should have 34 rows,
              # and all of these except results_table
              # should be printed (though some columns will be blank).
              self.assertEqual(len(row), 35)
              assert row["model_params"]
              assert row["grid_score"]
              assert row["score"]
              if use_additional_metrics:
                  assert row["additional_scores"]
  
              if row["learner_name"] == "LogisticRegression":
                  logistic_summary_score = float(row["score"])
                  if use_additional_metrics:
                      summary_metrics_dict = literal_eval(
                          row["additional_scores"]
                      )
                      logistic_summary_additional_score1 = float(
                          summary_metrics_dict["unweighted_kappa"]
                      )
                      logistic_summary_additional_score2 = float(
                          summary_metrics_dict["f1_score_micro"]
                      )
              elif row["learner_name"] == "MultinomialNB":
                  naivebayes_summary_score = float(row["score"])
                  if use_additional_metrics:
                      summary_metrics_dict = literal_eval(
                          row["additional_scores"]
                      )
                      nb_summary_additional_score1 = float(
                          summary_metrics_dict["unweighted_kappa"]
                      )
                      nb_summary_additional_score2 = float(
                          summary_metrics_dict["f1_score_micro"]
                      )
              elif row["learner_name"] == "SVC":
                  svm_summary_score = float(row["score"])
                  if use_additional_metrics:
                      summary_metrics_dict = literal_eval(
                          row["additional_scores"]
                      )
                      svm_summary_additional_score1 = float(
                          summary_metrics_dict["unweighted_kappa"]
                      )
                      svm_summary_additional_score2 = float(
                          summary_metrics_dict["f1_score_micro"]
                      )
  
      test_tuples = [
          (
              logistic_result_score,
              logistic_summary_score,
              "LogisticRegression",
          ),
          (svm_result_score, svm_summary_score, "SVC"),
      ]
  
      if use_additional_metrics:
          test_tuples.extend(
              [
                  (
                      logistic_result_additional_metric1,
                      logistic_summary_additional_score1,
                      "LogisticRegression",
                  ),
                  (
                      logistic_result_additional_metric2,
                      logistic_summary_additional_score2,
                      "LogisticRegression",
                  ),
                  (
                      svm_result_additional_metric1,
                      svm_summary_additional_score1,
                      "SVC",
                  ),
                  (
                      svm_result_additional_metric2,
                      svm_summary_additional_score2,
                      "SVC",
                  ),
              ]
          )
  
      if not use_feature_hashing:
          test_tuples.append(
              (
                  naivebayes_result_score,
                  naivebayes_summary_score,
                  "MultinomialNB",
              )
          )
          if use_additional_metrics:
              test_tuples.extend(
                  [
                      (
                          nb_result_additional_metric1,
                          nb_summary_additional_score1,
                          "MultinomialNB",
                      ),
                      (
                          nb_result_additional_metric2,
                          nb_summary_additional_score2,
                          "MultinomialNB",
                      ),
                  ]
              )
  
      for result_score, summary_score, learner_name in test_tuples:
          assert_almost_equal(
              result_score,
              summary_score,
              err_msg=f"mismatched scores for {learner_name} "
              f"(result:{result_score}, summary:{summary_score})",
          )
  
      # We iterate over each model with an expected
      # accuracy score. Test proves that the report
      # written out at least has a correct format for
      # this line. See _print_fancy_output
      if not use_feature_hashing and not use_additional_metrics:
          for report_name, val in (
              ("LogisticRegression", 0.5),
              ("MultinomialNB", 0.5),
              ("SVC", 0.6333),
          ):
              filename = (
                  f"test_summary_test_summary_{report_name}.results"
              )
              results_path = output_dir / filename
              with open(results_path) as results_file:
                  report = results_file.read()
                  expected_string = f"Accuracy = {val:.1f}"
                  self.assertEqual(
                      expected_string in report,  # approximate
                      True,
                      msg=f"{expected_string} is not in {report}",
                  )
  
imports: import csv
  import json
  import re
  import unittest
  import warnings
  from ast import literal_eval
  from collections import defaultdict
  from itertools import chain, product
  from pathlib import Path
  from unittest.mock import Mock, patch
  import numpy
  import pandas
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from sklearn.model_selection import ShuffleSplit, learning_curve
  from sklearn.naive_bayes import MultinomialNB
  from skll.data import FeatureSet, NDJReader, NDJWriter, Reader
  from skll.experiments import run_configuration
  from skll.experiments.output import _compute_ylimits_for_featureset
  from skll.learner import Learner
  from skll.utils.constants import VALID_TASKS
  from skll.utils.logging import close_and_remove_logger_handlers, get_skll_logger
  from skll.utils.testing import backward_compatibility_dir, config_dir, create_jsonlines_feature_files, fill_in_config_options, fill_in_config_paths, fill_in_config_paths_for_single_file, make_classification_data, make_digits_data, make_regression_data, other_dir, output_dir, remove_jsonlines_feature_files, test_dir, tests_dir, train_dir, unlink
label_desc: Use image node_id 5 for calling the TestOutput obj's underlying member method code with example usage: obj.check_summary_score(use_feature_hashing, use_additional_metrics) without return types