class_docstr: Test class for regression tests.
docstr: Test the descriptive statistics output in the results file for a regressor.
docstr_tok: ["Test","the","descriptive","statistics","output","in","the","results","file","for","a","regressor","."]
code: def test_fancy_output(self):
      """Test the descriptive statistics output in the results file for a regressor."""
      train_fs, test_fs, _ = make_regression_data(
          num_examples=2000, num_features=3
      )
  
      # train a regression model using the train feature set
      learner = Learner("LinearRegression")
      learner.train(
          train_fs, grid_search=True, grid_objective="pearson"
      )
  
      # evaluate the trained model using the test feature set
      resultdict = learner.evaluate(test_fs)
      actual_stats_from_api = dict(
          resultdict[2]["descriptive"]["actual"]
      )
      pred_stats_from_api = dict(
          resultdict[2]["descriptive"]["predicted"]
      )
  
      # write out the training and test feature set
      train_file = train_dir / "fancy_train.jsonlines"
      train_writer = NDJWriter(train_file, train_fs)
      train_writer.write()
      test_file = test_dir / "fancy_test.jsonlines"
      test_writer = NDJWriter(test_file, test_fs)
      test_writer.write()
  
      # now get the config file template, fill it in and run it
      # so that we can get a results file
      config_template_path = (
          config_dir / "test_regression_fancy_output.template.cfg"
      )
      config_path = fill_in_config_paths_for_fancy_output(
          config_template_path
      )
  
      run_configuration(config_path, quiet=True, local=True)
  
      # read in the results file and get the descriptive statistics
      actual_stats_from_file = {}
      pred_stats_from_file = {}
      with open(
          output_dir
          / "regression_fancy_output_train_fancy_train.jsonlines_test_"
          "fancy_test.jsonlines_LinearRegression.results"
      ) as resultf:
          result_output = resultf.read().strip().split("\n")
          for desc_stat_line in result_output[26:30]:
              desc_stat_line = desc_stat_line.strip()
              if not desc_stat_line:
                  continue
              else:
                  m = re.search(
                      r"([A-Za-z]+)\s+=\s+(-?[0-9]+.?[0-9]*)\s+\((actual)\),\s+"
                      r"(-?[0-9]+.?[0-9]*)\s+\((predicted)\)",
                      desc_stat_line,
                  )
                  stat_type, actual_value, _, pred_value, _ = m.groups()
                  actual_stats_from_file[stat_type.lower()] = float(
                      actual_value
                  )
                  pred_stats_from_file[stat_type.lower()] = float(
                      pred_value
                  )
  
      for stat_type in actual_stats_from_api:
          self.assertAlmostEqual(
              actual_stats_from_file[stat_type],
              actual_stats_from_api[stat_type],
              places=4,
          )
  
          self.assertAlmostEqual(
              pred_stats_from_file[stat_type],
              pred_stats_from_api[stat_type],
              places=4,
          )
  
imports: import math
  import re
  import unittest
  import warnings
  from itertools import chain, product
  import numpy
  from numpy.testing import assert_allclose, assert_array_equal
  from scipy.stats import pearsonr
  from sklearn.exceptions import ConvergenceWarning
  from sklearn.linear_model import LinearRegression, LogisticRegression
  from skll.config import _setup_config_parser
  from skll.data import FeatureSet, NDJReader, NDJWriter
  from skll.experiments import run_configuration
  from skll.learner import Learner
  from skll.learner.utils import rescaled
  from skll.utils.constants import CLASSIFICATION_ONLY_METRICS
  from skll.utils.testing import config_dir, fill_in_config_paths_for_fancy_output, make_regression_data, other_dir, output_dir, test_dir, train_dir, unlink
label_desc: Use image node_id 16 for calling the TestRegression obj's underlying member method code with example usage: obj.test_fancy_output() without return types