Skip to content

Should we use get_feature_names_out instead of get_feature_names? #711

@gaugup

Description

@gaugup

With a newer version of scikit-learn 1.2.0 we got the following error emanating from _causal_analysis.py:-

{
  "code": "ExecutionFailed",
  "category": "UserError",
  "message": {
    "NonCompliant": "Process 'python' exited with code 1 and error message 'Execution failed. Process exited with status code 1. Error: Traceback (most recent call last):\n  File \"create_causal.py\", line 121, in <module>\n    main(args)\n  File \"create_causal.py\", line 98, in main\n    rai_i.compute()\n  File \"/azureml-envs/azureml_6de821483c371657b39f098361948b90/lib/python3.8/site-packages/responsibleai/rai_insights/rai_insights.py\", line 389, in compute\n    manager.compute()\n  File \"/azureml-envs/azureml_6de821483c371657b39f098361948b90/lib/python3.8/site-packages/responsibleai/managers/causal_manager.py\", line 341, in compute\n    policy = self._create_policy(\n  File \"/azureml-envs/azureml_6de821483c371657b39f098361948b90/lib/python3.8/site-packages/responsibleai/managers/causal_manager.py\", line 244, in _create_policy\n    tree = causal_analysis._policy_tree_output(\n  File \"/azureml-envs/azureml_6de821483c371657b39f098361948b90/lib/python3.8/site-packages/econml/solutions/causal_analysis/_causal_analysis.py\", line 1520, in _policy_tree_output\n    (policy_val, always_trt)) = self._tree(True, Xtest, feature_index,\n  File \"/azureml-envs/azureml_6de821483c371657b39f098361948b90/lib/python3.8/site-packages/econml/solutions/causal_analysis/_causal_analysis.py\", line 1441, in _tree\n    return intrp, result.X_transformer.get_feature_names(self.feature_names_), treatment_names, policy_values\n  File \"/azureml-envs/azureml_6de821483c371657b39f098361948b90/lib/python3.8/site-packages/econml/solutions/causal_analysis/_causal_analysis.py\", line 228, in get_feature_names\n    cats = self.one_hot_encoder.get_feature_names(\nAttributeError: 'OneHotEncoder' object has no attribute 'get_feature_names'\n'. Please check the log file 'user_logs/std_log.txt' for more details."
  },
  "details": [
    {
      "name": "exit_codes",
      "value": {
        "Literal": {
          "Compliant": "1"
        }
      }
    }
  ],
  "error": null,
  "node_info": null
}

Looks like the method get_feature_names is deprecated in newer version of scikit-learn. Is it possible to change to API get_feature_names_out?

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