dodiscover.metrics.confusion_matrix_networks#
- dodiscover.metrics.confusion_matrix_networks(true_graph, pred_graph, labels=None, normalize=None)[source]#
Compute the confusion matrix comparing a predicted graph from the true graph.
Converts the graphs into an undirected graph, and then compares their adjacency matrix, which are symmetric.
- Parameters:
- true_graphinstance of causal graph
The true graph.
- pred_graphinstance of causal graph
The predicted graph. The predicted graph and true graph must be the same type.
- labelsarray_like of shape (n_classes), default=None
List of labels to index the matrix. This may be used to reorder or select a subset of labels. If
None
is given, those that appear at least once iny_true
ory_pred
are used in sorted order.- normalize{‘true’, ‘pred’, ‘all’}, default=None
Normalizes confusion matrix over the true (rows), predicted (columns) conditions or all the population. If None, confusion matrix will not be normalized.
- Returns:
- cm
np.ndarray
of shape (2, 2) The confusion matrix.
- cm
See also
Notes
This function only compares the graph’s adjacency structure, which does not take into consideration the directionality of edges.