class_docstr: Base class for algebraic representation of Structural Equation Models(SEMs). The model is
  represented using the Reticular Action Model (RAM).
class_docstr_tok: ["Base","class","for","algebraic","representation","of","Structural","Equation","Models","(","SEMs",")",".","The","model","is","represented","using","the","Reticular","Action","Model","(","RAM",")","."]
docstr: Initializes SEMAlg model. The model is represented using the Reticular Action Model(RAM)
  which is given as:
  ..math::
      \mathbf{\eta} = \mathbf{B \eta} + \mathbf{\zeta}
      \mathbf{y} = \mathbf{\wedge_y \eta}
  
  where :math:`\mathbf{\eta}` is the set of all the observed and latent variables in the
  model, :math:`\mathbf{y}` are the set of observed variables, :math:`\mathbf{\zeta}` is
  the error terms for :math:`\mathbf{\eta}`, and \mathbf{\wedge_y} is a boolean array to
  select the observed variables from :math:`\mathbf{\eta}`.
  
  Parameters
  ----------
  The following set of parameters are used to set the learnable parameters in the model.
  To specify the values of the parameter use the `fixed_values` parameter. Either `eta`,
  `B`, `zeta`, and `wedge_y`, or `fixed_values` need to be specified.
  
  eta: list/array-like
      The name of the variables in the model.
  
  B: 2-D array (boolean)
      The learnable parameters in the `B` matrix.
  
  zeta: 2-D array (boolean)
      The learnable parameters in the covariance matrix of the error terms.
  
  wedge_y: 2-D array
      The `wedge_y` matrix.
  
  fixed_params: dict (default: None)
      A dict of fixed values for parameters.
  
      If None all the parameters specified by `B`, and `zeta` are learnable.
  
  Returns
  -------
  pgmpy.models.SEMAlg instance: An instance of the object with initalized values.
  
  Examples
  --------
  >>> from pgmpy.models import SEMAlg
  # TODO: Finish this example
docstr_tok: ["Initializes","SEMAlg","model",".","The","model","is","represented","using","the","Reticular","Action","Model","(","RAM",")","which","is","given","as",":","..","math",":",":","\\mathbf","{","\\eta","}","=","\\mathbf","{","B","\\eta","}","+","\\mathbf","{","\\zeta","}","\\mathbf","{","y","}","=","\\mathbf","{","\\wedge_y","\\eta","}","where",":","math",":","`","\\mathbf","{","\\eta","}","`","is","the","set","of","all","the","observed","and","latent","variables","in","the","model",",",":","math",":","`","\\mathbf","{","y","}","`","are","the","set","of","observed","variables",",",":","math",":","`","\\mathbf","{","\\zeta","}","`","is","the","error","terms","for",":","math",":","`","\\mathbf","{","\\eta","}","`",",","and","\\mathbf","{","\\wedge_y","}","is","a","boolean","array","to","select","the","observed","variables","from",":","math",":","`","\\mathbf","{","\\eta","}","`",".","Parameters","--","--","--","--","--","The","following","set","of","parameters","are","used","to","set","the","learnable","parameters","in","the","model",".","To","specify","the","values","of","the","parameter","use","the","`","fixed_values","`","parameter",".","Either","`","eta","`",",","`","B","`",",","`","zeta","`",",","and","`","wedge_y","`",",","or","`","fixed_values","`","need","to","be","specified",".","eta",":","list\/array-like","The","name","of","the","variables","in","the","model",".","B",":","2-D","array","(","boolean",")","The","learnable","parameters","in","the","`","B","`","matrix",".","zeta",":","2-D","array","(","boolean",")","The","learnable","parameters","in","the","covariance","matrix","of","the","error","terms",".","wedge_y",":","2-D","array","The","`","wedge_y","`","matrix",".","fixed_params",":","dict","(","default",":","None",")","A","dict","of","fixed","values","for","parameters",".","If","None","all","the","parameters","specified","by","`","B","`",",","and","`","zeta","`","are","learnable",".","Returns","--","--","--","-","pgmpy.models.SEMAlg","instance",":","An","instance","of","the","object","with","initalized","values",".","Examples","--","--","--","--",">",">",">","from","pgmpy.models","import","SEMAlg","#","TODO",":","Finish","this","example"]
code: def __init__(
      self, eta=None, B=None, zeta=None, wedge_y=None, fixed_values=None
  ):
      r"""
      Initializes SEMAlg model. The model is represented using the Reticular Action Model(RAM)
      which is given as:
      ..math::
          \mathbf{\eta} = \mathbf{B \eta} + \mathbf{\zeta}
          \mathbf{y} = \mathbf{\wedge_y \eta}
  
      where :math:`\mathbf{\eta}` is the set of all the observed and latent variables in the
      model, :math:`\mathbf{y}` are the set of observed variables, :math:`\mathbf{\zeta}` is
      the error terms for :math:`\mathbf{\eta}`, and \mathbf{\wedge_y} is a boolean array to
      select the observed variables from :math:`\mathbf{\eta}`.
  
      Parameters
      ----------
      The following set of parameters are used to set the learnable parameters in the model.
      To specify the values of the parameter use the `fixed_values` parameter. Either `eta`,
      `B`, `zeta`, and `wedge_y`, or `fixed_values` need to be specified.
  
      eta: list/array-like
          The name of the variables in the model.
  
      B: 2-D array (boolean)
          The learnable parameters in the `B` matrix.
  
      zeta: 2-D array (boolean)
          The learnable parameters in the covariance matrix of the error terms.
  
      wedge_y: 2-D array
          The `wedge_y` matrix.
  
      fixed_params: dict (default: None)
          A dict of fixed values for parameters.
  
          If None all the parameters specified by `B`, and `zeta` are learnable.
  
      Returns
      -------
      pgmpy.models.SEMAlg instance: An instance of the object with initalized values.
  
      Examples
      --------
      >>> from pgmpy.models import SEMAlg
      # TODO: Finish this example
      """
      self.eta = eta
      self.B = np.array(B)
      self.zeta = np.array(zeta)
      self.wedge_y = wedge_y
  
      # Get the observed variables
      self.y = []
      for row_i in range(self.wedge_y.shape[0]):
          for index, val in enumerate(self.wedge_y[row_i]):
              if val:
                  self.y.append(self.eta[index])
  
      if fixed_values:
          self.B_fixed_mask = fixed_values["B"]
          self.zeta_fixed_mask = fixed_values["zeta"]
      else:
          self.B_fixed_mask = np.zeros(self.B.shape)
          self.zeta_fixed_mask = np.zeros(self.zeta.shape)
  
      # Masks represent the parameters which need to be learnt while training.
      self.B_mask = np.multiply(
          np.where(self.B_fixed_mask != 0, 0.0, 1.0), self.B
      )
      self.zeta_mask = np.multiply(
          np.where(self.zeta_fixed_mask != 0, 0.0, 1.0), self.zeta
      )
  
imports: import itertools
  import networkx
  import numpy
  import pandas
  from networkx.algorithms.dag import descendants
  from pyparsing import OneOrMore, Optional, Suppress, Word, alphanums, nums
  from pgmpy.base import DAG
  from pgmpy.global_vars import logger
label_desc: Use image node_id 1 to create a new SEMAlg object  with example: obj = SEMAlg(eta, B, zeta, wedge_y, fixed_values)