docstr: Intializes CFs and other related variables.
docstr_tok: ["Intializes","CFs","and","other","related","variables","."]
code: def do_cf_initializations(
      self,
      total_CFs,
      initialization,
      algorithm,
      features_to_vary,
      desired_range,
      desired_class,
      query_instance,
      query_instance_df_dummies,
      verbose,
  ):
      """Intializes CFs and other related variables."""
      self.cf_init_weights = [total_CFs, algorithm, features_to_vary]
  
      if algorithm == "RandomInitCF":
          # no. of times to run the experiment with random inits for diversity
          self.total_random_inits = total_CFs
          self.total_CFs = 1  # size of counterfactual set
      else:
          self.total_random_inits = 0
          self.total_CFs = total_CFs  # size of counterfactual set
  
      # freeze those columns that need to be fixed
      self.features_to_vary = features_to_vary
  
      # CF initialization
      self.cfs = []
      if initialization == "random":
          self.cfs = self.do_random_init(
              self.population_size,
              features_to_vary,
              query_instance,
              desired_class,
              desired_range,
          )
  
      elif initialization == "kdtree":
          # Partitioned dataset and KD Tree for each class (binary) of the dataset
          (
              self.dataset_with_predictions,
              self.KD_tree,
              self.predictions,
          ) = self.build_KD_tree(
              self.data_interface.data_df.copy(),
              desired_range,
              desired_class,
              self.predicted_outcome_name,
          )
          if self.KD_tree is None:
              self.cfs = self.do_random_init(
                  self.population_size,
                  features_to_vary,
                  query_instance,
                  desired_class,
                  desired_range,
              )
  
          else:
              num_queries = min(
                  len(self.dataset_with_predictions),
                  self.population_size * self.total_CFs,
              )
              indices = self.KD_tree.query(
                  query_instance_df_dummies, num_queries
              )[1][0]
              KD_tree_output = self.dataset_with_predictions.iloc[
                  indices
              ].copy()
              self.do_KD_init(
                  features_to_vary,
                  query_instance,
                  KD_tree_output,
                  desired_class,
                  desired_range,
              )
  
      if verbose:
          print(
              "Initialization complete! Generating counterfactuals..."
          )
  
imports: import copy
  import random
  import timeit
  import numpy
  import pandas
  from raiutils.exceptions import UserConfigValidationException
  from dice_ml import diverse_counterfactuals
  from dice_ml.constants import ModelTypes
  from dice_ml.explainer_interfaces.explainer_base import ExplainerBase
label_desc: Use image node_id 6 for calling the DiceGenetic obj's underlying member method code with example usage: obj.do_cf_initializations(total_CFs, initialization, algorithm, features_to_vary, desired_range, desired_class, query_instance, query_instance_df_dummies, verbose) without return types