code: def typify_classification(vec):
      # Per scikit-learn, we need to accept y of list or numpy array that contains either strings or integers.
      # We want to serialize these models to/from JSON, and JSON allows us to differentiate between string
      # and integer types with just the JSON type, so that's nice.  JSON also allows boolean types,
      # and that seems like a type someone might pass us for binary classification, so accept bools too.
      # https://scikit-learn.org/stable/developers/develop.html
  
      if issubclass(vec.dtype.type, np.integer):
          # this also handles pandas Int8Dtype to Int64Dtype, UInt8Dtype to UInt64Dtype
          # JSON has a number datatype, so we can preserve this information in JSON!
          dtype = np.int64
      elif issubclass(vec.dtype.type, np.bool_):
          # this also handles pandas BooleanDtype
          # JSON has a boolean datatype, so we can preserve this information in JSON!
          dtype = np.bool_
      elif issubclass(vec.dtype.type, np.object_):
          types = set(map(type, vec))
          if all(
              one_type is int or issubclass(one_type, np.integer)
              for one_type in types
          ):
              # the vec.astype call below can fail if we're passed an unsigned np.uint64
              # array with big values, but we don't want to surprise anyone by converting to
              # strings in that special case, so throw if we're presented this unusual type
              dtype = np.int64
          elif all(
              one_type is bool or issubclass(one_type, np.bool_)
              for one_type in types
          ):
              dtype = np.bool_
          else:
              dtype = np.unicode_
      else:
          dtype = np.unicode_
  
      return vec.astype(dtype, copy=False)
  
file_path: interpret/python/interpret-core/interpret/utils/_clean_simple.py
imports: import numpy
  import numpy.ma
  from sklearn.base import is_classifier, is_regressor
  from ._clean_x import preclean_X
  from ._link import link_func
  import logging
label_desc: Use image node_id 3 for calling a global function with example usage: typify_classification(vec) and returns: vec