Skip to content

Raised error for one-hot encoded data with generic method #446

Description

@Gradwanderer

I have preprocessed a data set with one-hot encoding for all categorical features. The data has now more than 30 binary (hot encoded) (0,1) features. If I try to run the "genetic", I get the error shown below.

Do I need to specify the (0,1) encoded features?
The change to random does provide CFE, but I guess the "random method" is not the optimal solution to get the best possible CFE.

File "C:\CFE.py", line 158, in gen_cfe
e1 = exp.generate_counterfactuals(downsampled_dataset, total_CFs=10, desired_class="opposite")# "opposite")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:.venv\Lib\site-packages\dice_ml\explainer_interfaces\explainer_base.py", line 186, in generate_counterfactuals
res = self.generate_counterfactuals(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:.venv\Lib\site-packages\dice_ml\explainer_interfaces\dice_genetic.py", line 270, in generate_counterfactuals
self.num_output_nodes = self.model.get_num_output_nodes2(query_instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:.venv\Lib\site-packages\dice_ml\model_interfaces\base_model.py", line 70, in get_num_output_nodes2
return self.get_output(input_instance).shape[1]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:.venv\Lib\site-packages\dice_ml\model_interfaces\base_model.py", line 54, in get_output
return self.model.predict_proba(input_instance)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:.venv\Lib\site-packages\pyod\models\base.py", line 213, in predict_proba
test_scores = self.decision_function(X)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:.venv\Lib\site-packages\pyod\models\pca.py", line 300, in decision_function
cdist(X, self.selected_components
) / self.selected_w_components
,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:.venv\Lib\site-packages\scipy\spatial\distance.py", line 3006, in cdist
return cdist_fn(XA, XB, out=out, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Unsupported dtype object

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions