class_docstr: Computes Mutual Information(MI) between each feature and the label.
  
  The non-streaming sk-learn implementation of MI is used to
  estimate Adjusted Mutual Information(AMI) and MI between all valid features
  and the label. AMI prevents overestimation of MI for high entropy features.
  It is defined as MI(feature, labels) - MI(feature, np.random.shuffle(labels)).
  
  SkLearnMutualInformation will "gracefully fail" on all features
  that are multivalent since they are not supported by sk-learn. The compute
  method will not report statistics for these invalid features.
docstr: Encodes all categorical features in input dataframe to numeric values.
  
  Categorical features are inferred from the schema. They are transformed
  using the np.unique function which maps each value in the feature's domain
  to a numeric id. Encoded categorical features are marked by a boolean mask
  which is returned and used by scikit-learn to identify discrete features.
  
  Args:
    df: A pd.DataFrame containing feature values where each column corresponds
      to a feature and each row corresponds to an example.
  
  Returns:
    A boolean list where the ith element is true iff the ith feature column in
    the input df is a categorical feature.
docstr_tok: ["Encodes","all","categorical","features","in","input","dataframe","to","numeric","values",".","Categorical","features","are","inferred","from","the","schema",".","They","are","transformed","using","the","np.unique","function","which","maps","each","value","in","the","feature","'s","domain","to","a","numeric","id",".","Encoded","categorical","features","are","marked","by","a","boolean","mask","which","is","returned","and","used","by","scikit-learn","to","identify","discrete","features",".","Args",":","df",":","A","pd.DataFrame","containing","feature","values","where","each","column","corresponds","to","a","feature","and","each","row","corresponds","to","an","example",".","Returns",":","A","boolean","list","where","the","ith","element","is","true","iff","the","ith","feature","column","in","the","input","df","is","a","categorical","feature","."]
code: def _convert_categorical_features_to_numeric(
      self, df: pd.DataFrame
  ) -> List[bool]:
      """Encodes all categorical features in input dataframe to numeric values.
  
      Categorical features are inferred from the schema. They are transformed
      using the np.unique function which maps each value in the feature's domain
      to a numeric id. Encoded categorical features are marked by a boolean mask
      which is returned and used by scikit-learn to identify discrete features.
  
      Args:
        df: A pd.DataFrame containing feature values where each column corresponds
          to a feature and each row corresponds to an example.
  
      Returns:
        A boolean list where the ith element is true iff the ith feature column in
        the input df is a categorical feature.
      """
      is_categorical_feature = [False for _ in df]
      columns_to_drop = []
      indices_to_drop = []
      for i, column in enumerate(df):
          if column in self._categorical_features:
              # Encode categorical columns.
              def maybe_decode_or_impute(x):
                  if isinstance(x, bytes):
                      return x.decode("utf-8", "replace")
                  elif x is not None:
                      return x
                  else:
                      return _CATEGORICAL_FEATURE_IMPUTATION_FILL_VALUE
  
              str_array = [
                  maybe_decode_or_impute(x) for x in df[column].values
              ]
              unique_elements, df[column] = np.unique(
                  str_array, return_inverse=True
              )
              is_categorical_feature[i] = True
              # Drop the categroical features that all its values are unique if the
              # label is not categorical.
              # Otherwise such feature will cause error during MI calculation.
              if (
                  unique_elements.size == df[column].shape[0]
                  and not self._label_feature_is_categorical
              ):
                  columns_to_drop.append(column)
                  indices_to_drop.append(i)
      df.drop(columns_to_drop, axis=1, inplace=True)
      is_categorical_feature = np.delete(
          is_categorical_feature, indices_to_drop
      )
      return is_categorical_feature
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import sys
  from typing import Dict, List, Optional, Sequence, Set, Text, Union
  import numpy
  import pandas
  import pyarrow
  from tensorflow_data_validation import types
  from tensorflow_data_validation.arrow import arrow_util
  from tensorflow_data_validation.statistics.generators import partitioned_stats_generator
  from tensorflow_data_validation.utils import schema_util
  from tensorflow_data_validation.utils import stats_util
  from tfx_bsl.arrow import array_util
  from tensorflow_metadata.proto.v0 import schema_pb2
  from tensorflow_metadata.proto.v0 import statistics_pb2
label_desc: Use image node_id 4 for calling the SkLearnMutualInformation obj's underlying member method code with example usage: obj._convert_categorical_features_to_numeric(df) and returns: is_categorical_feature, x, x, _CATEGORICAL_FEATURE_IMPUTATION_FILL_VALUE