class_docstr: Result of causal analysis.
class_docstr_tok: ["Result","of","causal","analysis","."]
docstr: Attempt to parse a categorical comparison from a policy tree node.
  
  The default assumption is that the feature is continuous and will
  have a real-valued threshold.
  
  This function checks known categorical features and attempts to parse
  a (feature, category) pair that would come from a one-hot encoding.
  
  Example (continuous):
      Original feature: "Size"
      Original comparison value: 0.891
      Parsed feature: "Size"
      Parsed comparison: "gt"
      Parsed comparison value: 0.891
  
  Example (categorical):
      Original feature: "Fruit_apple"
      Original comparison value: 0.5
      Parsed feature: "Fruit"
      Parsed comparison: "eq"
      Parsed comparison value: "apple"
docstr_tok: ["Attempt","to","parse","a","categorical","comparison","from","a","policy","tree","node",".","The","default","assumption","is","that","the","feature","is","continuous","and","will","have","a","real-valued","threshold",".","This","function","checks","known","categorical","features","and","attempts","to","parse","a","(","feature",",","category",")","pair","that","would","come","from","a","one-hot","encoding",".","Example","(","continuous",")",":","Original","feature",":","``","Size","''","Original","comparison","value",":","0.891","Parsed","feature",":","``","Size","''","Parsed","comparison",":","``","gt","''","Parsed","comparison","value",":","0.891","Example","(","categorical",")",":","Original","feature",":","``","Fruit_apple","''","Original","comparison","value",":","0.5","Parsed","feature",":","``","Fruit","''","Parsed","comparison",":","``","eq","''","Parsed","comparison","value",":","``","apple","''"]
code: def _parse_comparison(
      cls,
      policy_tree: Any,
      categoricals: List[str],
  ) -> Tuple[str, str, Union[float, int, str]]:
      """Attempt to parse a categorical comparison from a policy tree node.
  
      The default assumption is that the feature is continuous and will
      have a real-valued threshold.
  
      This function checks known categorical features and attempts to parse
      a (feature, category) pair that would come from a one-hot encoding.
  
      Example (continuous):
          Original feature: "Size"
          Original comparison value: 0.891
          Parsed feature: "Size"
          Parsed comparison: "gt"
          Parsed comparison value: 0.891
  
      Example (categorical):
          Original feature: "Fruit_apple"
          Original comparison value: 0.5
          Parsed feature: "Fruit"
          Parsed comparison: "eq"
          Parsed comparison value: "apple"
  
      """
      tree_feature = policy_tree[ResultAttributes.FEATURE]
      threshold = policy_tree[ResultAttributes.THRESHOLD]
  
      # Default assumption is a continuous feature
      feature = tree_feature
      comparison = ComparisonTypes.GT
      value = threshold
  
      # Check for a categorical feature
      for cat_feature in sorted(categoricals)[::-1]:
          pattern = f"({cat_feature})_(.+)"
          match = re.match(pattern, tree_feature)
          if match is not None:
              feature = match.group(1)
              value = match.group(2)
              comparison = ComparisonTypes.EQ
              break
  
      return feature, comparison, value
  
imports: import json
  import re
  import uuid
  from pathlib import Path
  from typing import Any, List, Optional, Tuple, Union
  import pandas
  import semver
  from responsibleai._interfaces import CausalConfig
  from responsibleai._interfaces import CausalData, CausalPolicy, CausalPolicyGains, CausalPolicyTreeInternal, CausalPolicyTreeLeaf, ComparisonTypes
  from responsibleai._internal.constants import FileFormats, SerializationAttributes
  from responsibleai._tools.causal.causal_config import CausalConfig
  from responsibleai._tools.causal.causal_constants import ResultAttributes
  from responsibleai._tools.shared.base_result import BaseResult
  from responsibleai._tools.shared.versions import CausalVersions
label_desc: Use image node_id 15 for calling the CausalResult obj's underlying member method code with example usage: obj._parse_comparison(cls, policy_tree, categoricals) and returns: feature,  comparison,  value