class_docstr: Defines the CounterfactualManager for generating counterfactuals
  from a model.
class_docstr_tok: ["Defines","the","CounterfactualManager","for","generating","counterfactuals","from","a","model","."]
docstr: Add a counterfactual generation configuration to be computed later.
  
  :param total_CFs: Total number of counterfactuals required.
  :type total_CFs: int
  :param method: Type of dice-ml explainer. Either of "random", "genetic"
      or "kdtree".
  :type method: str
  :param desired_class: Desired counterfactual class. For binary
      classification, this needs to be set as "opposite".
  :type desired_class: string or int
  :param desired_range: For regression problems.
      Contains the outcome range to generate counterfactuals in.
  :type desired_range: list
  :param permitted_range: Dictionary with feature names as keys and
      permitted range in list as values. Defaults to the range inferred
      from training data.
  :type permitted_range: dict
  :param features_to_vary: Either a string "all" or a list of
      feature names to vary.
  :type features_to_vary: list
  :param feature_importance: Flag to compute feature importance using
      dice-ml.
  :type feature_importance: bool
code: def add(
      self,
      total_CFs: int,
      method: str = CounterfactualConstants.RANDOM,
      desired_class: Optional[Union[str, int]] = None,
      desired_range: Optional[List] = None,
      permitted_range: Optional[dict] = None,
      features_to_vary: Union[str, List[str]] = "all",
      feature_importance: bool = True,
  ):
      """Add a counterfactual generation configuration to be computed later.
  
      :param total_CFs: Total number of counterfactuals required.
      :type total_CFs: int
      :param method: Type of dice-ml explainer. Either of "random", "genetic"
          or "kdtree".
      :type method: str
      :param desired_class: Desired counterfactual class. For binary
          classification, this needs to be set as "opposite".
      :type desired_class: string or int
      :param desired_range: For regression problems.
          Contains the outcome range to generate counterfactuals in.
      :type desired_range: list
      :param permitted_range: Dictionary with feature names as keys and
          permitted range in list as values. Defaults to the range inferred
          from training data.
      :type permitted_range: dict
      :param features_to_vary: Either a string "all" or a list of
          feature names to vary.
      :type features_to_vary: list
      :param feature_importance: Flag to compute feature importance using
          dice-ml.
      :type feature_importance: bool
      """
      if self._categorical_features is None:
          continuous_features = list(
              set(self._train.columns) - set([self._target_column])
          )
      else:
          continuous_features = list(
              set(self._train.columns)
              - set([self._target_column])
              - set(self._categorical_features)
          )
  
      counterfactual_config = CounterfactualConfig(
          method=method,
          continuous_features=continuous_features,
          total_CFs=total_CFs,
          desired_class=desired_class,
          desired_range=desired_range,
          permitted_range=permitted_range,
          features_to_vary=features_to_vary,
          feature_importance=feature_importance,
      )
  
      self._add_counterfactual_config(counterfactual_config)
  
imports: import json
  import uuid
  import warnings
  from pathlib import Path
  from typing import Any, List, Optional, Union
  import dice_ml
  import jsonschema
  import numpy
  import pandas
  from dice_ml import Dice
  from dice_ml.counterfactual_explanations import CounterfactualExplanations
  from dice_ml.explainer_interfaces.explainer_base import ExplainerBase
  from raiutils.exceptions import UserConfigValidationException
  from raiutils.models import ModelTask
  from responsibleai._config.base_config import BaseConfig
  from responsibleai._data_validations import validate_train_test_categories
  from responsibleai._interfaces import CounterfactualData
  from responsibleai._internal.constants import CounterfactualManagerKeys, FileFormats, ListProperties, ManagerNames
  from responsibleai._tools.shared.state_directory_management import DirectoryManager
  from responsibleai.exceptions import DuplicateManagerConfigException, SchemaErrorException
  from responsibleai.managers.base_manager import BaseManager
  from responsibleai.utils import _find_features_having_missing_values, _measure_time
label_desc: Use image node_id 4 for calling the CounterfactualManager obj's underlying member method code with example usage: obj.add(total_CFs, method, desired_class, desired_range, permitted_range, features_to_vary, feature_importance) without return types