evaluate

Evaluate estimated CStrees.

cslearn.evaluate.KL_divergence(df_distr1, df_distr2)[source]

Calculate the KL divergence between two distributions using scipy rel_entr. df_distr2 is typically the true distribution and df_distr1 is the estimated distribution.

cslearn.evaluate.kl_divergence(estimated: CStree, true: CStree) float[source]

KL divergence D(estimated || true) between two CStree distributions.

Parameters:
  • estimated – The estimated CStree. Its labels must be a permutation of true.labels.

  • true – The true CStree. Its labels must be sorted (true.labels == sorted(true.labels)); outcomes are enumerated in that order.

Returns:

KL divergence (non-negative; 0 iff distributions are identical).

Return type:

float

cslearn.evaluate.shd_ldag(estimated: CStree, true: CStree) int[source]

Structural Hamming distance between two CStrees via their LDAG representations.

Counts missing edges, extra edges, and reversed edges between the LDAGs. A reversal counts as 1, not 2.