class_docstr: Test class for cross-validation tests.
class_docstr_tok: ["Test","class","for","cross-validation","tests","."]
docstr: Test to make sure that the fold ids get returned correctly after cross-validation.
docstr_tok: ["Test","to","make","sure","that","the","fold","ids","get","returned","correctly","after","cross-validation","."]
code: def test_retrieve_cv_folds(self):
      """Test to make sure that the fold ids get returned correctly after cross-validation."""
      # Setup
      learner = Learner("LogisticRegression")
      num_folds = 5
      cv_fs, custom_cv_folds = self.make_cv_folds_data(
          num_examples_per_fold=2, num_folds=num_folds
      )
  
      # Test 1: learner.cross_validate() makes the folds itself.
      expected_fold_ids = {
          "EXAMPLE_0": "0",
          "EXAMPLE_1": "4",
          "EXAMPLE_2": "3",
          "EXAMPLE_3": "1",
          "EXAMPLE_4": "2",
          "EXAMPLE_5": "2",
          "EXAMPLE_6": "1",
          "EXAMPLE_7": "0",
          "EXAMPLE_8": "4",
          "EXAMPLE_9": "3",
      }
      _, _, _, skll_fold_ids, _ = learner.cross_validate(
          cv_fs,
          stratified=True,
          cv_folds=num_folds,
          grid_search=True,
          grid_objective="f1_score_micro",
          shuffle=False,
      )
      self.assertEqual(skll_fold_ids, expected_fold_ids)
  
      # Test 2: if we pass in custom fold ids, those are also preserved.
      _, _, _, skll_fold_ids, _ = learner.cross_validate(
          cv_fs,
          stratified=True,
          cv_folds=custom_cv_folds,
          grid_search=True,
          grid_objective="f1_score_micro",
          shuffle=False,
      )
      self.assertEqual(skll_fold_ids, custom_cv_folds)
  
      # Test 3: when learner.cross_validate() makes the folds but stratified=False
      # and grid_search=False, so that KFold is used.
      expected_fold_ids = {
          "EXAMPLE_0": "0",
          "EXAMPLE_1": "0",
          "EXAMPLE_2": "1",
          "EXAMPLE_3": "1",
          "EXAMPLE_4": "2",
          "EXAMPLE_5": "2",
          "EXAMPLE_6": "3",
          "EXAMPLE_7": "3",
          "EXAMPLE_8": "4",
          "EXAMPLE_9": "4",
      }
      _, _, _, skll_fold_ids, _ = learner.cross_validate(
          cv_fs,
          stratified=False,
          cv_folds=num_folds,
          grid_search=False,
          shuffle=False,
      )
      self.assertEqual(skll_fold_ids, custom_cv_folds)
  
imports: import csv
  import itertools
  import json
  import re
  import unittest
  import numpy
  from numpy.testing import assert_almost_equal
  from sklearn.datasets import make_classification
  from sklearn.feature_extraction import FeatureHasher
  from skll.config import load_cv_folds
  from skll.data import FeatureSet
  from skll.experiments import load_featureset, run_configuration
  from skll.learner import Learner
  from skll.utils.testing import compute_expected_folds_for_cv_testing, config_dir, create_jsonlines_feature_files, fill_in_config_paths_for_single_file, other_dir, output_dir, remove_jsonlines_feature_files, train_dir, unlink
label_desc: Use image node_id 7 for calling the TestCrossValidation obj's underlying member method code with example usage: obj.test_retrieve_cv_folds() without return types