class_docstr: Represents an post nonlinear FCM, i.e. models of the form:
      Y = g(f(X) + N),
  where X are parent nodes of the target node Y, f an arbitrary prediction model expecting inputs from the
  parents X, N a noise variable and g an invertible function.
class_docstr_tok: ["Represents","an","post","nonlinear","FCM",",","i.e",".","models","of","the","form",":","Y","=","g","(","f","(","X",")","+","N",")",",","where","X","are","parent","nodes","of","the","target","node","Y",",","f","an","arbitrary","prediction","model","expecting","inputs","from","the","parents","X",",","N","a","noise","variable","and","g","an","invertible","function","."]
docstr: Fits the post non-linear model of the form Y = g(f(X) + N). Here, this consists of three steps given
  samples from (X, Y):
  
      1. Transform Y via the inverse of g: g^-1(Y) = f(X) + N
      2. Fit the model for f on (X, g^-1(Y))
      3. Reconstruct N based on the residual N = g^-1(Y) - f(X)
  
  Note that the noise here can be inferred uniquely if the model assumption holds.
  
  :param X: Samples from the input X.
  :param Y: Samples from the target Y.
  :return: None
docstr_tok: ["Fits","the","post","non-linear","model","of","the","form","Y","=","g","(","f","(","X",")","+","N",")",".","Here",",","this","consists","of","three","steps","given","samples","from","(","X",",","Y",")",":","1",".","Transform","Y","via","the","inverse","of","g",":","g^-1","(","Y",")","=","f","(","X",")","+","N","2",".","Fit","the","model","for","f","on","(","X",",","g^-1","(","Y",")",")","3",".","Reconstruct","N","based","on","the","residual","N","=","g^-1","(","Y",")","-","f","(","X",")","Note","that","the","noise","here","can","be","inferred","uniquely","if","the","model","assumption","holds",".",":","param","X",":","Samples","from","the","input","X.",":","param","Y",":","Samples","from","the","target","Y.",":","return",":","None"]
code: def fit(self, X: np.ndarray, Y: np.ndarray) -> None:
      """Fits the post non-linear model of the form Y = g(f(X) + N). Here, this consists of three steps given
      samples from (X, Y):
  
          1. Transform Y via the inverse of g: g^-1(Y) = f(X) + N
          2. Fit the model for f on (X, g^-1(Y))
          3. Reconstruct N based on the residual N = g^-1(Y) - f(X)
  
      Note that the noise here can be inferred uniquely if the model assumption holds.
  
      :param X: Samples from the input X.
      :param Y: Samples from the target Y.
      :return: None
      """
      X, Y = shape_into_2d(X, Y)
  
      self._prediction_model.fit(
          X=X, Y=self._invertible_function.evaluate_inverse(Y)
      )
      self._noise_model.fit(X=self.estimate_noise(Y, X))
  
imports: import copy
  from abc import ABC, abstractmethod
  from typing import List, Optional
  import numpy
  from dowhy.gcm.ml import ClassificationModel, PredictionModel
  from dowhy.gcm.ml.regression import InvertibleFunction, SklearnRegressionModel
  from dowhy.gcm.util.general import is_categorical, is_discrete, shape_into_2d
label_desc: Use image node_id 2 for calling the PostNonlinearModel obj's underlying member method code with example usage: obj.fit(X, Y) without return types