Analytics

CausalDisco.analytics.order_alignment(W, scores, tol=0.0)[source]

Computes a measure of the agreement between a causal ordering following the topology of the (weighted) adjacency matrix W and an ordering by the scores.

Parameters:
  • W – Weighted/Binary DAG adjacency matrix (\(d \times d\) np.array).

  • scores – Vector of scores (np.array with \(d\) entries).

  • tol (optional) – Tolerance threshold for score comparisons (non-negative float).

Returns:

Scalar measure of agreement between the orderings.

CausalDisco.analytics.r2_sortability(X, W, tol=0.0)[source]

Sortability by \(R^2\).

Parameters:
  • X – Data (\(n \times d\) np.array).

  • W – Weighted/Binary ground-truth DAG adjacency matrix (\(d \times d\) np.array).

Returns:

\(R^2\)-sortability value (\(\in [0, 1]\)) of the data

CausalDisco.analytics.r2coeff(X)[source]

Compute the \(R^2\) of each variable using partial correlations obtained through matrix inversion.

Parameters:

X – Data (\(d \times n\) np.array - note that the dimensions here are different from other methods, following np.corrcoef).

Returns:

Array of \(R^2\) values for all variables.

CausalDisco.analytics.snr_sortability(X, W, tol=0.0)[source]

Sortability by signal-to-noise (SnR) ratio (also referred to as cause-explained variance CEV).

Parameters:
  • X – Data (\(n \times d\) np.array).

  • W – Weighted/Binary ground-truth DAG adjacency matrix (\(d \times d\) np.array).

Returns:

math: SnR-sortability value (\(\in [0, 1]\)) of the data

CausalDisco.analytics.var_sortability(X, W, tol=0.0)[source]

Sortability by variance.

Parameters:
  • X – Data (\(n \times d\) np.array).

  • W – Weighted/Binary ground-truth DAG adjacency matrix (\(d \times d\) np.array).

Returns:

Var-sortability value (\(\in [0, 1]\)) of the data