class_docstr: A class to pre-process targets.
  
  It validates the data provided during fit to make sure it matches Sklearn
  expectation as well as encoding the targets in case of classification
  
  Attributes
  ----------
  is_classification: bool
      A bool that indicates if the validator should operate in classification mode.
      During classification, the targets are encoded.
  
  encoder: Optional[BaseEstimator]
      Host a encoder object if the data requires transformation (for example, if
      provided a categorical column in a pandas DataFrame).
  
  enc_columns: List[str]
      List of columns that where encoded
class_docstr_tok: ["A","class","to","pre-process","targets",".","It","validates","the","data","provided","during","fit","to","make","sure","it","matches","Sklearn","expectation","as","well","as","encoding","the","targets","in","case","of","classification","Attributes","--","--","--","--","--","is_classification",":","bool","A","bool","that","indicates","if","the","validator","should","operate","in","classification","mode",".","During","classification",",","the","targets","are","encoded",".","encoder",":","Optional","[","BaseEstimator","]","Host","a","encoder","object","if","the","data","requires","transformation","(","for","example",",","if","provided","a","categorical","column","in","a","pandas","DataFrame",")",".","enc_columns",":","List","[","str","]","List","of","columns","that","where","encoded"]
docstr: Revert any encoding transformation done on a target array.
  
  Parameters
  ----------
  y: Union[List, np.ndarray, pd.DataFrame, pd.Series]
      Target array to be transformed back to original form before encoding
  
  Return
  ------
  np.ndarray:
      The transformed array
docstr_tok: ["Revert","any","encoding","transformation","done","on","a","target","array",".","Parameters","--","--","--","--","--","y",":","Union","[","List",",","np.ndarray",",","pd.DataFrame",",","pd.Series","]","Target","array","to","be","transformed","back","to","original","form","before","encoding","Return","--","--","--","np.ndarray",":","The","transformed","array"]
code: def inverse_transform(
      self,
      y: Union[List, pd.Series, pd.DataFrame, np.ndarray],
  ) -> np.ndarray:
      """Revert any encoding transformation done on a target array.
  
      Parameters
      ----------
      y: Union[List, np.ndarray, pd.DataFrame, pd.Series]
          Target array to be transformed back to original form before encoding
  
      Return
      ------
      np.ndarray:
          The transformed array
      """
      if not self._is_fitted:
          raise NotFittedError(
              "TargetValidator must have fit() called first"
          )
  
      # If there's no encoder, just return it as the expected ndarray
      if self.encoder is None:
          return np.asarray(y)
  
      # If it's one dimensional, we need to convert it
      # [1,2,3] -> [[1], [2], [3]]
      shape = np.shape(y)
      if len(shape) == 1:
          if isinstance(y, pd.DataFrame) or isinstance(y, pd.Series):
              y = y.to_numpy()
          elif isinstance(y, List):
              y = np.asarray(y)
  
          # Perform the transformation and reshape it
          y = y.reshape(-1, 1)
          y_inv = self.encoder.inverse_transform(y)
          y_inv = y_inv.reshape(-1)
  
      else:
          # Otherwise we can can just invert it as expected
          y_inv = self.encoder.inverse_transform(y)
  
      # Inverse transform returns a numpy array of type object
      # This breaks certain metrics as accuracy, which makes type_of_target be unknown
      # If while fit a dtype was observed, we try to honor that dtype
      if self.dtype is not None:
          y_inv = y_inv.astype(self.dtype)
  
      return y_inv
  
imports: from typing import List, Optional, Type, Union, cast
  import logging
  import warnings
  import numpy
  import pandas
  import sklearn.utils
  from pandas.api.types import is_numeric_dtype
  from pandas.core.dtypes.base import ExtensionDtype
  from scipy.sparse import spmatrix
  from sklearn.base import BaseEstimator
  from sklearn.exceptions import NotFittedError
  from sklearn.preprocessing import OrdinalEncoder
  from sklearn.utils.multiclass import type_of_target
  from autosklearn.util.logging_ import PickableLoggerAdapter
label_desc: Use image node_id 5 for calling the TargetValidator obj's underlying member method code with example usage: obj.inverse_transform(y) and returns: y_inv, np