class_docstr: Test class for cross-validation tests.
class_docstr_tok: ["Test","class","for","cross-validation","tests","."]
docstr: Create data for pre-specified CV folds tests with or without feature hashing.
docstr_tok: ["Create","data","for","pre-specified","CV","folds","tests","with","or","without","feature","hashing","."]
code: def make_cv_folds_data(
      self,
      num_examples_per_fold=100,
      num_folds=3,
      use_feature_hashing=False,
  ):
      """Create data for pre-specified CV folds tests with or without feature hashing."""
      num_total_examples = num_examples_per_fold * num_folds
  
      # create the numeric features and the binary labels
      X, _ = make_classification(
          n_samples=num_total_examples,
          n_features=3,
          n_informative=3,
          n_redundant=0,
          n_classes=2,
          random_state=1234567890,
      )
      y = np.array([0, 1] * int(num_total_examples / 2))
  
      # the folds mapping: the first num_examples_per_fold examples
      # are in fold 1 the second num_examples_per_fold are in
      # fold 2 and so on
      foldgen = (
          [str(i)] * num_examples_per_fold for i in range(num_folds)
      )
      folds = list(itertools.chain(*foldgen))
  
      # now create the list of feature dictionaries
      # and add the binary features that depend on
      # the class and fold number
      feature_names = [f"f{i}" for i in range(1, 4)]
      features = []
      for row, classid, foldnum in zip(X, y, folds):
          string_feature_name = f"is_{classid}_{foldnum}"
          string_feature_value = 1
          feat_dict = dict(zip(feature_names, row))
          feat_dict.update({string_feature_name: string_feature_value})
          features.append(feat_dict)
  
      # create the example IDs
      ids = [
          f"EXAMPLE_{num_examples_per_fold * k + i}"
          for k in range(num_folds)
          for i in range(num_examples_per_fold)
      ]
  
      # create the cross-validation feature set with or without feature hashing
      vectorizer = (
          FeatureHasher(n_features=4) if use_feature_hashing else None
      )
      cv_fs = FeatureSet(
          "cv_folds",
          ids,
          features=features,
          labels=y,
          vectorizer=vectorizer,
      )
  
      # make the custom cv folds dictionary
      custom_cv_folds = dict(zip(ids, folds))
  
      return cv_fs, 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 3 for calling the TestCrossValidation obj's underlying member method code with example usage: obj.make_cv_folds_data(num_examples_per_fold, num_folds, use_feature_hashing) and returns: cv_fs,  custom_cv_folds