jpt.base.correlation

Correlation measures.

Standalone mathematical correlation functions with no JPT-specific knowledge.

Submodules

Functions

xi_correlation(→ float)

Compute Chatterjee's xi correlation.

xi_correlation_matrix(→ numpy.ndarray)

Compute xi for all feature-target pairs.

Package Contents

jpt.base.correlation.xi_correlation(x: numpy.ndarray, y: numpy.ndarray) float

Compute Chatterjee’s xi correlation.

Measures the degree to which y is a measurable function of x. Requires only two sorts and a linear pass, giving O(n log n) complexity.

Parameters:
  • x – feature values, shape (n,)

  • y – target values, shape (n,)

Returns:

xi coefficient in [-0.5, 1]

jpt.base.correlation.xi_correlation_matrix(data: numpy.ndarray, feature_indices: numpy.ndarray, target_indices: numpy.ndarray, row_indices: numpy.ndarray | None = None) numpy.ndarray

Compute xi for all feature-target pairs.

Returns a matrix M where M[i, j] = xi(data[:, feature_indices[i]],

data[:, target_indices[j]]).

Parameters:
  • data – array (n x d)

  • feature_indices – feature column indices

  • target_indices – target column indices

  • row_indices – optional row subset

Returns:

xi matrix (nf x nt)