class_docstr: A class to store and visualize the resulting counterfactual explanations.
class_docstr_tok: ["A","class","to","store","and","visualize","the","resulting","counterfactual","explanations","."]
code: def from_json(cf_example_json_str):
      cf_example_dict = json.loads(cf_example_json_str)
      if (
          cf_example_dict.get(
              _DiverseCFV1SchemaConstants.TEST_INSTANCE_DF
          )
          is not None
      ):
          test_instance_df = pd.read_json(
              cf_example_dict[
                  _DiverseCFV1SchemaConstants.TEST_INSTANCE_DF
              ]
          )
          if (
              cf_example_dict[_DiverseCFV1SchemaConstants.FINAL_CFS_DF]
              is not None
          ):
              cfs_df = pd.read_json(
                  cf_example_dict[
                      _DiverseCFV1SchemaConstants.FINAL_CFS_DF
                  ]
              )
          else:
              cfs_df = None
  
          # Creating the object for dummy_data_interface
          dummy_data_interface = DummyDataInterface(
              **cf_example_dict[
                  _DiverseCFV1SchemaConstants.DATA_INTERFACE
              ]
          )
          return CounterfactualExamples(
              data_interface=dummy_data_interface,
              test_instance_df=test_instance_df,
              final_cfs_df=cfs_df,
              final_cfs_df_sparse=cfs_df,
              posthoc_sparsity_param=None,
              desired_class=cf_example_dict[
                  _DiverseCFV1SchemaConstants.DESIRED_CLASS
              ],
              desired_range=cf_example_dict[
                  _DiverseCFV1SchemaConstants.DESIRED_RANGE
              ],
              model_type=cf_example_dict[
                  _DiverseCFV1SchemaConstants.MODEL_TYPE
              ],
          )
      else:
          final_cfs_list = cf_example_dict[
              _DiverseCFV2SchemaConstants.FINAL_CFS_LIST
          ]
          test_instance_list = cf_example_dict[
              _DiverseCFV2SchemaConstants.TEST_INSTANCE_LIST
          ]
          feature_names_including_target = cf_example_dict[
              _DiverseCFV2SchemaConstants.FEATURE_NAMES_INCLUDING_TARGET
          ]
  
          data_interface = cf_example_dict[
              _DiverseCFV2SchemaConstants.DATA_INTERFACE
          ]
          desired_class = cf_example_dict[
              _DiverseCFV2SchemaConstants.DESIRED_CLASS
          ]
          desired_range = cf_example_dict[
              _DiverseCFV2SchemaConstants.DESIRED_RANGE
          ]
          model_type = cf_example_dict[
              _DiverseCFV2SchemaConstants.MODEL_TYPE
          ]
  
          test_instance_df = pd.DataFrame(
              data=test_instance_list,
              columns=feature_names_including_target,
          )
          if final_cfs_list is not None:
              cfs_df = pd.DataFrame(
                  data=final_cfs_list,
                  columns=feature_names_including_target,
              )
          else:
              cfs_df = None
          # Creating the object for dummy_data_interface
          dummy_data_interface = DummyDataInterface(**data_interface)
          return CounterfactualExamples(
              data_interface=dummy_data_interface,
              test_instance_df=test_instance_df,
              final_cfs_df=cfs_df,
              final_cfs_df_sparse=cfs_df,
              posthoc_sparsity_param=None,
              desired_class=desired_class,
              desired_range=desired_range,
              model_type=model_type,
          )
  
imports: import copy
  import json
  import math
  import numpy
  import pandas
  from dice_ml.constants import ModelTypes, _SchemaVersions
  from dice_ml.utils.serialize import DummyDataInterface
label_desc: Use image node_id 10 for calling the CounterfactualExamples obj's underlying member method code with example usage: obj.from_json(cf_example_json_str) and returns: CounterfactualExamples, CounterfactualExamples