class_docstr: Test class for output tests.
code: def check_xval_fancy_results_file(
      self,
      do_grid_search,
      use_folds_file,
      use_folds_file_for_grid_search,
      use_additional_metrics,
  ):
      train_path = train_dir / "f0.jsonlines"
  
      # make a simple config file for cross-validation
      values_to_fill_dict = {
          "experiment_name": "test_fancy_xval",
          "train_file": str(train_path),
          "task": "cross_validate",
          "grid_search": "true",
          "objectives": "['f1_score_micro']",
          "featureset_names": '["f0"]',
          "num_cv_folds": "6",
          "grid_search_folds": "4",
          "learners": "['LogisticRegression']",
          "logs": str(output_dir),
          "predictions": str(output_dir),
          "results": str(output_dir),
      }
  
      folds_file_path = train_dir / "folds_file_test.csv"
      if use_folds_file:
          values_to_fill_dict["folds_file"] = str(folds_file_path)
      values_to_fill_dict["grid_search"] = str(do_grid_search)
      values_to_fill_dict["use_folds_file_for_grid_search"] = str(
          use_folds_file_for_grid_search
      )
  
      if use_additional_metrics:
          values_to_fill_dict["metrics"] = str(
              ["accuracy", "unweighted_kappa"]
          )
  
      config_template_path = config_dir / "test_fancy.template.cfg"
  
      config_path = fill_in_config_options(
          config_template_path, values_to_fill_dict, "xval"
      )
  
      # run the experiment
      run_configuration(config_path, quiet=True, local=True)
  
      # now make sure that the results file was produced
      results_file_path = (
          output_dir / "test_fancy_xval_f0_LogisticRegression.results"
      )
      self.assertTrue(results_file_path.exists())
  
      # read in all the lines and look at the lines up to where we print the "Total Time"
      with open(results_file_path) as resultsf:
          results_lines = resultsf.readlines()
          end_idx = [
              results_lines.index(l)
              for l in results_lines  # noqa: E741
              if l.startswith("Total Time:")
          ][0]
          results_lines = results_lines[: end_idx + 1]
  
          # read in the "keys" and "values" separated by colons into a dictionary
          results_dict = dict(
              [rl.strip().split(": ") for rl in results_lines]
          )
  
      # check that the fields we expect in the results file are there
      # and the ones that we do not expect aren't
      if do_grid_search:
          self.assertEqual(results_dict["Grid Search"], "True")
          self.assertEqual(
              results_dict["Grid Objective Function"], "f1_score_micro"
          )
      else:
          self.assertEqual(results_dict["Grid Search"], "False")
          self.assertTrue("Grid Search Folds" not in results_dict)
          self.assertTrue("Grid Objective Function" not in results_dict)
  
      if use_folds_file:
          self.assertEqual(
              results_dict["Number of Folds"], "5 via folds file"
          )
          self.assertTrue("Stratified Folds" not in results_dict)
          self.assertEqual(
              results_dict["Specified Folds File"], str(folds_file_path)
          )
          if do_grid_search:
              if use_folds_file_for_grid_search:
                  self.assertEqual(
                      results_dict["Grid Search Folds"],
                      "5 via folds file",
                  )
                  self.assertEqual(
                      results_dict["Using Folds File for Grid Search"],
                      "True",
                  )
              else:
                  self.assertEqual(
                      results_dict["Grid Search Folds"], "4"
                  )
                  self.assertEqual(
                      results_dict["Using Folds File for Grid Search"],
                      "False",
                  )
      else:
          self.assertEqual(results_dict["Number of Folds"], "6")
          self.assertEqual(results_dict["Stratified Folds"], "True")
          self.assertTrue(
              "Using Folds File for Grid Search" not in results_dict
          )
          self.assertTrue("Specified Folds File" not in results_dict)
          if do_grid_search:
              self.assertEqual(results_dict["Grid Search Folds"], "4")
  
      if use_additional_metrics:
          expected_metrics = ["accuracy", "unweighted_kappa"]
  
          self.assertEqual(
              sorted(
                  literal_eval(
                      results_dict["Additional Evaluation Metrics"]
                  )
              ),
              sorted(expected_metrics),
          )
  
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 7 for calling the TestOutput obj's underlying member method code with example usage: obj.check_xval_fancy_results_file(do_grid_search, use_folds_file, use_folds_file_for_grid_search, use_additional_metrics) without return types