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: Creates a graph structure from the LISREL representation.
  
  Returns
  -------
  pgmpy.models.SEMGraph instance: A path model of the model.
  
  Examples
  --------
  >>> from pgmpy.models import SEMAlg
  >>> model = SEMAlg()
  # TODO: Finish this example
docstr_tok: ["Creates","a","graph","structure","from","the","LISREL","representation",".","Returns","--","--","--","-","pgmpy.models.SEMGraph","instance",":","A","path","model","of","the","model",".","Examples","--","--","--","--",">",">",">","from","pgmpy.models","import","SEMAlg",">",">",">","model","=","SEMAlg","(",")","#","TODO",":","Finish","this","example"]
code: def to_SEMGraph(self):
      """
      Creates a graph structure from the LISREL representation.
  
      Returns
      -------
      pgmpy.models.SEMGraph instance: A path model of the model.
  
      Examples
      --------
      >>> from pgmpy.models import SEMAlg
      >>> model = SEMAlg()
      # TODO: Finish this example
      """
  
      err_var = {
          var: np.diag(self.zeta)[i] for i, var in enumerate(self.eta)
      }
      graph = nx.relabel_nodes(
          nx.from_numpy_array(self.B.T, create_using=nx.DiGraph),
          mapping={i: self.eta[i] for i in range(self.B.shape[0])},
      )
      # Fill zeta diagonal with 0's as they represent variance and would add self loops in the graph.
      zeta = self.zeta.copy()
      np.fill_diagonal(zeta, 0)
      err_graph = nx.relabel_nodes(
          nx.from_numpy_array(zeta.T, create_using=nx.Graph),
          mapping={i: self.eta[i] for i in range(self.zeta.shape[0])},
      )
  
      latents = set(self.eta) - set(self.y)
  
      from pgmpy.models import SEMGraph
  
      # TODO: Add edge weights
      sem_graph = SEMGraph(
          ebunch=graph.edges(),
          latents=latents,
          err_corr=err_graph.edges(),
          err_var=err_var,
      )
      return sem_graph
  
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 2 for calling the SEMAlg obj's underlying member method code with example usage: obj.to_SEMGraph() and returns: sem_graph