class_docstr: Class for performing approximate inference using Max-Product Linear Programming method.
  
  We derive message passing updates that result in monotone decrease of the dual of the
  MAP LP Relaxation.
  
  Parameters
  ----------
  model: MarkovNetwork for which inference is to be performed.
  
  Examples
  --------
  >>> import numpy as np
  >>> from pgmpy.models import MarkovNetwork
  >>> from pgmpy.inference import Mplp
  >>> from pgmpy.factors.discrete import DiscreteFactor
  >>> student = MarkovNetwork()
  >>> student.add_edges_from([('A', 'B'), ('B', 'C'), ('C', 'D'), ('E', 'F')])
  >>> factor_a = DiscreteFactor(['A'], cardinality=[2], values=np.array([0.54577, 1.8323]))
  >>> factor_b = DiscreteFactor(['B'], cardinality=[2], values=np.array([0.93894, 1.065]))
  >>> factor_c = DiscreteFactor(['C'], cardinality=[2], values=np.array([0.89205, 1.121]))
  >>> factor_d = DiscreteFactor(['D'], cardinality=[2], values=np.array([0.56292, 1.7765]))
  >>> factor_e = DiscreteFactor(['E'], cardinality=[2], values=np.array([0.47117, 2.1224]))
  >>> factor_f = DiscreteFactor(['F'], cardinality=[2], values=np.array([1.5093, 0.66257]))
  >>> factor_a_b = DiscreteFactor(['A', 'B'], cardinality=[2, 2],
  ...                             values=np.array([1.3207, 0.75717, 0.75717, 1.3207]))
  >>> factor_b_c = DiscreteFactor(['B', 'C'], cardinality=[2, 2],
  ...                             values=np.array([0.00024189, 4134.2, 4134.2, 0.00024189]))
  >>> factor_c_d = DiscreteFactor(['C', 'D'], cardinality=[2, 2],
  ...                             values=np.array([0.0043227, 231.34, 231.34, 0.0043227]))
  >>> factor_d_e = DiscreteFactor(['E', 'F'], cardinality=[2, 2],
  ...                             values=np.array([31.228, 0.032023, 0.032023, 31.228]))
  >>> student.add_factors(factor_a, factor_b, factor_c, factor_d, factor_e, factor_f, factor_a_b,
  ...                     factor_b_c, factor_c_d, factor_d_e)
  >>> mplp = Mplp(student)
class_docstr_tok: ["Class","for","performing","approximate","inference","using","Max-Product","Linear","Programming","method",".","We","derive","message","passing","updates","that","result","in","monotone","decrease","of","the","dual","of","the","MAP","LP","Relaxation",".","Parameters","--","--","--","--","--","model",":","MarkovNetwork","for","which","inference","is","to","be","performed",".","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","from","pgmpy.models","import","MarkovNetwork",">",">",">","from","pgmpy.inference","import","Mplp",">",">",">","from","pgmpy.factors.discrete","import","DiscreteFactor",">",">",">","student","=","MarkovNetwork","(",")",">",">",">","student.add_edges_from","(","[","(","'","A","'",",","'","B","'",")",",","(","'","B","'",",","'","C","'",")",",","(","'","C","'",",","'D","'",")",",","(","'","E","'",",","'","F","'",")","]",")",">",">",">","factor_a","=","DiscreteFactor","(","[","'","A","'","]",",","cardinality=","[","2","]",",","values=np.array","(","[","0.54577",",","1.8323","]",")",")",">",">",">","factor_b","=","DiscreteFactor","(","[","'","B","'","]",",","cardinality=","[","2","]",",","values=np.array","(","[","0.93894",",","1.065","]",")",")",">",">",">","factor_c","=","DiscreteFactor","(","[","'","C","'","]",",","cardinality=","[","2","]",",","values=np.array","(","[","0.89205",",","1.121","]",")",")",">",">",">","factor_d","=","DiscreteFactor","(","[","'D","'","]",",","cardinality=","[","2","]",",","values=np.array","(","[","0.56292",",","1.7765","]",")",")",">",">",">","factor_e","=","DiscreteFactor","(","[","'","E","'","]",",","cardinality=","[","2","]",",","values=np.array","(","[","0.47117",",","2.1224","]",")",")",">",">",">","factor_f","=","DiscreteFactor","(","[","'","F","'","]",",","cardinality=","[","2","]",",","values=np.array","(","[","1.5093",",","0.66257","]",")",")",">",">",">","factor_a_b","=","DiscreteFactor","(","[","'","A","'",",","'","B","'","]",",","cardinality=","[","2",",","2","]",",","...","values=np.array","(","[","1.3207",",","0.75717",",","0.75717",",","1.3207","]",")",")",">",">",">","factor_b_c","=","DiscreteFactor","(","[","'","B","'",",","'","C","'","]",",","cardinality=","[","2",",","2","]",",","...","values=np.array","(","[","0.00024189",",","4134.2",",","4134.2",",","0.00024189","]",")",")",">",">",">","factor_c_d","=","DiscreteFactor","(","[","'","C","'",",","'D","'","]",",","cardinality=","[","2",",","2","]",",","...","values=np.array","(","[","0.0043227",",","231.34",",","231.34",",","0.0043227","]",")",")",">",">",">","factor_d_e","=","DiscreteFactor","(","[","'","E","'",",","'","F","'","]",",","cardinality=","[","2",",","2","]",",","...","values=np.array","(","[","31.228",",","0.032023",",","0.032023",",","31.228","]",")",")",">",">",">","student.add_factors","(","factor_a",",","factor_b",",","factor_c",",","factor_d",",","factor_e",",","factor_f",",","factor_a_b",",","...","factor_b_c",",","factor_c_d",",","factor_d_e",")",">",">",">","mplp","=","Mplp","(","student",")"]
docstr: Returns the score of each of the triplets found in the current model
  
  Parameters
  ---------
  triangles_list: list
                  The list of variables forming the triangles to be updated. It is of the form of
                  [['var_5', 'var_8', 'var_7'], ['var_4', 'var_5', 'var_7']]
  
  Return: {frozenset({'var_8', 'var_5', 'var_7'}): 5.024, frozenset({'var_5', 'var_4', 'var_7'}): 10.23}
docstr_tok: ["Returns","the","score","of","each","of","the","triplets","found","in","the","current","model","Parameters","--","--","--","--","-","triangles_list",":","list","The","list","of","variables","forming","the","triangles","to","be","updated",".","It","is","of","the","form","of","[","[","'var_5","'",",","'var_8","'",",","'var_7","'","]",",","[","'var_4","'",",","'var_5","'",",","'var_7","'","]","]","Return",":","{","frozenset","(","{","'var_8","'",",","'var_5","'",",","'var_7","'","}",")",":","5.024",",","frozenset","(","{","'var_5","'",",","'var_4","'",",","'var_7","'","}",")",":","10.23","}"]
code: def _get_triplet_scores(self, triangles_list):
      """
      Returns the score of each of the triplets found in the current model
  
      Parameters
      ---------
      triangles_list: list
                      The list of variables forming the triangles to be updated. It is of the form of
                      [['var_5', 'var_8', 'var_7'], ['var_4', 'var_5', 'var_7']]
  
      Return: {frozenset({'var_8', 'var_5', 'var_7'}): 5.024, frozenset({'var_5', 'var_4', 'var_7'}): 10.23}
      """
      triplet_scores = {}
      for triplet in triangles_list:
          # Find the intersection sets of the current triplet
          triplet_intersections = [
              intersect for intersect in it.combinations(triplet, 2)
          ]
  
          # Independent maximization
          ind_max = sum(
              [
                  np.amax(self.objective[frozenset(intersect)].values)
                  for intersect in triplet_intersections
              ]
          )
  
          # Joint maximization
          joint_max = self.objective[
              frozenset(triplet_intersections[0])
          ]
          for intersect in triplet_intersections[1:]:
              joint_max += self.objective[frozenset(intersect)]
          joint_max = np.amax(joint_max.values)
          # score = Independent maximization solution - Joint maximization solution
          score = ind_max - joint_max
          triplet_scores[frozenset(triplet)] = score
  
      return triplet_scores
  
imports: import copy
  import itertools
  import networkx
  import numpy
  from pgmpy.factors.discrete import DiscreteFactor
  from pgmpy.inference import Inference
  from pgmpy.models import MarkovNetwork
label_desc: Use image node_id 7 for calling the Mplp obj's underlying member method code with example usage: obj._get_triplet_scores(triangles_list) and returns: triplet_scores