class_docstr: Base class of SEM estimators. All the estimators inherit this class.
class_docstr_tok: ["Base","class","of","SEM","estimators",".","All","the","estimators","inherit","this","class","."]
docstr: Method to compute the Weighted Least Squares fitting function. The optimizer calls
  this method after each iteration with updated params to compute the new loss.
  
  The fitting function for ML is:
  .. math:: F_{ULS} = tr \{ [(S - \Sigma(\theta)) W^{-1}]^2 \}
  
  Parameters
  ----------
  params: dict
      params contain all the variables which are updated in each iteration of the
      optimization.
  
  loss_args: dict
      loss_args contain all the variable which are not updated in each iteration but
      are required to compute the loss.
  
  Returns
  -------
  torch.tensor: The loss value for the given params and loss_args
docstr_tok: ["Method","to","compute","the","Weighted","Least","Squares","fitting","function",".","The","optimizer","calls","this","method","after","each","iteration","with","updated","params","to","compute","the","new","loss",".","The","fitting","function","for","ML","is",":","..","math",":",":","F_","{","ULS","}","=","tr","\\","{","[","(","S","-","\\Sigma","(","\\theta",")",")","W^","{","-1","}","]","^2","\\","}","Parameters","--","--","--","--","--","params",":","dict","params","contain","all","the","variables","which","are","updated","in","each","iteration","of","the","optimization",".","loss_args",":","dict","loss_args","contain","all","the","variable","which","are","not","updated","in","each","iteration","but","are","required","to","compute","the","loss",".","Returns","--","--","--","-","torch.tensor",":","The","loss","value","for","the","given","params","and","loss_args"]
code: def gls_loss(self, params, loss_args):
      r"""
      Method to compute the Weighted Least Squares fitting function. The optimizer calls
      this method after each iteration with updated params to compute the new loss.
  
      The fitting function for ML is:
      .. math:: F_{ULS} = tr \{ [(S - \Sigma(\theta)) W^{-1}]^2 \}
  
      Parameters
      ----------
      params: dict
          params contain all the variables which are updated in each iteration of the
          optimization.
  
      loss_args: dict
          loss_args contain all the variable which are not updated in each iteration but
          are required to compute the loss.
  
      Returns
      -------
      torch.tensor: The loss value for the given params and loss_args
      """
      S = loss_args["S"]
      W_inv = pinverse(loss_args["W"])
      sigma = self._get_implied_cov(params["B"], params["zeta"])
      return ((S - sigma) @ W_inv).pow(2).trace()
  
file_path: pgmpy/pgmpy/estimators/SEMEstimator.py
imports: import numpy
  import pandas
  import statsmodels.api
  import torch
  from pgmpy import config
  from pgmpy.models import SEM, SEMAlg, SEMGraph
  from pgmpy.utils import optimize, pinverse
label_desc: Use image node_id 5 for calling the SEMEstimator obj's underlying member method code with example usage: obj.gls_loss(params, loss_args) and returns: unknown