helpers

pgmpy bridge

helpers.pgmpy_bridge.to_openbnsl(pgmpy_pdag, col_str2idx)

Convert a pgmpy PDAG to an OpenBNSL PDAG.

Parameters:
  • pgmpy_pdag (PgmpyPDAG) – The pgmpy PDAG to convert.

  • col_str2idx (dict[str, int]) – A mapping from variable names to their indices.

Returns:

The converted OpenBNSL PDAG.

Return type:

OpenBNSLPDAG

helpers.pgmpy_bridge.to_pgmpy(openbnsl_pdag, node_labels)

Convert an OpenBNSL PDAG to a pgmpy PDAG.

Parameters:
  • openbnsl_pdag (OpenBNSLPDAG) – The OpenBNSL PDAG to convert.

  • node_labels (list[str]) – A list of node labels corresponding to the variables in the PDAG.

Returns:

The converted pgmpy PDAG.

Return type:

PgmpyPDAG

Structural Distance

helpers.structural_distance.PDAG2CPDAG(pdag)

Compute the completed partially directed acyclic graph (CPDAG) of a given PDAG. :param pdag: The input PDAG to convert. :type pdag: PDAG

Returns:

The completed PDAG.

Return type:

PDAG

Parameters:

pdag (PDAG)

helpers.structural_distance.structural_errors(ground_truth_pdag, predicted_graph)

Compute structural errors between two PDAGs. :param ground_truth_pdag: The ground truth PDAG. :type ground_truth_pdag: PDAG :param predicted_graph: The predicted PDAG. :type predicted_graph: PDAG

Returns:

A dictionary containing the structural errors: - SHD: Structural Hamming Distance (= EE + ME + DE) - ME: Missing Edge (ground truth has edge, prediction does not) - EE: Extra Edge (prediction has edge, ground truth does not) - DE: Directional Error (= ED + MD + RD) - ED: Extra Direction (undirected in ground truth, directed in prediction) - MD: Missing Direction (directed in ground truth, undirected in prediction) - RD: Reversed Direction (X -> Y in ground truth, Y -> X in prediction)

Return type:

dict

Parameters:
  • ground_truth_pdag (PDAG)

  • predicted_graph (PDAG)