CorrelationMatrix

CorrelationMatrix()

Represent and validate a numeric correlation matrix.

Attributes

Name Description
model_config dict() -> new empty dictionary

Methods

Name Description
from_n_corr Create an n by n matrix with a shared off-diagonal correlation.
from_numpy Create a correlation matrix from a NumPy array.
plot Plot the correlation matrix as an annotated heatmap.
to_numpy Return the correlation matrix as a NumPy array.
validate_matrix Validate shape, correlation bounds, symmetry, and PSD-ness.

from_n_corr

CorrelationMatrix.from_n_corr(n, corr)

Create an n by n matrix with a shared off-diagonal correlation.

from_numpy

CorrelationMatrix.from_numpy(arr)

Create a correlation matrix from a NumPy array.

plot

CorrelationMatrix.plot(
    ax=None,
    *,
    labels=None,
    cmap='Spectral',
    show=False,
    colorbar=True,
    **imshow_kwargs,
)

Plot the correlation matrix as an annotated heatmap.

Returns the Matplotlib Axes object. Importing Matplotlib is deferred so non-plotting use stays lightweight. Extra keyword arguments are passed to imshow.

to_numpy

CorrelationMatrix.to_numpy()

Return the correlation matrix as a NumPy array.

validate_matrix

CorrelationMatrix.validate_matrix(matrix)

Validate shape, correlation bounds, symmetry, and PSD-ness.