class_docstr: Evaluator for targeted molecule discovery task. Metric is the mean, optimum, and good percentage of property scores among generated molecular geometries.
  
  Args:
      prop_name (str): A string indicating the name of the molecular property, use 'gap' for HOMO-LUMO gap or 'alpha' for 
          isotropic polarizability. (default: :obj:`gap`)
      good_threshold (float): The threshold used to identifying whether a property score is good or not. Use 4.5 for HOMO-LUMO gap, and lower than 4.5 is considered
          as good. Use 91 for isotropic polarizability, and higher than 91 is considered as good.
docstr: Run evaluation in the targeted molecule discovery task.
  
  Args:
      mol_dicts (dict): A python dict where the key is the number of atoms, and the value indexed by that key is another python dict storing the atomic
          number matrix (indexed by the key '_atomic_numbers') and the coordinate tensor (indexed by the key '_positions') of all generated molecular geometries with that atom number. 
      
  :rtype: :class:`dict` a python dict with the following items:
              mean --- the mean of property scores;
              best --- the optimum of property scores, it is the lowest value for HOMO-LUMO gap, and the highest value for isotropic polarizability;
              good_per --- the good percentage of property scores.
docstr_tok: ["Run","evaluation","in","the","targeted","molecule","discovery","task",".","Args",":","mol_dicts","(","dict",")",":","A","python","dict","where","the","key","is","the","number","of","atoms",",","and","the","value","indexed","by","that","key","is","another","python","dict","storing","the","atomic","number","matrix","(","indexed","by","the","key","'_atomic_numbers","'",")","and","the","coordinate","tensor","(","indexed","by","the","key","'_positions","'",")","of","all","generated","molecular","geometries","with","that","atom","number",".",":","rtype",":",":","class",":","`","dict","`","a","python","dict","with","the","following","items",":","mean","--","-","the","mean","of","property","scores",";","best","--","-","the","optimum","of","property","scores",",","it","is","the","lowest","value","for","HOMO-LUMO","gap",",","and","the","highest","value","for","isotropic","polarizability",";","good_per","--","-","the","good","percentage","of","property","scores","."]
code: def eval(self, mol_dicts):
      r"""Run evaluation in the targeted molecule discovery task.
  
      Args:
          mol_dicts (dict): A python dict where the key is the number of atoms, and the value indexed by that key is another python dict storing the atomic
              number matrix (indexed by the key '_atomic_numbers') and the coordinate tensor (indexed by the key '_positions') of all generated molecular geometries with that atom number.
  
      :rtype: :class:`dict` a python dict with the following items:
                  mean --- the mean of property scores;
                  best --- the optimum of property scores, it is the lowest value for HOMO-LUMO gap, and the highest value for isotropic polarizability;
                  good_per --- the good percentage of property scores.
      """
  
      results = {}
  
      prop_list = []
      for num_atoms in mol_dicts:
          atomic_numbers, positions = (
              mol_dicts[num_atoms]["_atomic_numbers"],
              mol_dicts[num_atoms]["_positions"],
          )
          for atomic_number, position in zip(atomic_numbers, positions):
              _, valid = xyz2mol(atomic_number, position)
              if not valid:
                  continue
              prop_list.append(
                  compute_prop(atomic_number, position, self.prop_name)
              )
  
      mean = np.mean(prop_list)
      if self.prop_name == "gap":
          best = np.min(prop_list)
          good_per = np.sum(
              np.array(prop_list) <= self.good_threshold
          ) / len(prop_list)
      elif self.prop_name == "alpha":
          best = np.max(prop_list)
          good_per = np.sum(
              np.array(prop_list) >= self.good_threshold
          ) / len(prop_list)
  
      print(
          "Mean: {}, best: {}, good percentage: {:.2f}".format(
              mean, best, good_per * 100
          )
      )
  
      results["mean"] = mean
      results["best"] = best
      results["good_per"] = good_per
      return results
  
file_path: DIG/dig/ggraph3D/evaluation/metric.py
imports: import torch
  import numpy
  from dig.ggraph3D.utils import xyz2mol, collect_bond_dists, compute_mmd, compute_prop
label_desc: Use image node_id 2 for calling the PropOptEvaluator obj's underlying member method code with example usage: obj.eval(mol_dicts) and returns: results