Skip to main content

CovarianceMatrixExplorer

Explorer
DashAI.back.exploration.explorers.CovarianceMatrixExplorer

Explorer that computes and visualises the pairwise covariance matrix.

Unlike the correlation matrix, covariance values are not normalised to the [-1, 1] range, so they retain the original units of the features. A large positive covariance between two columns means they tend to increase together, while a large negative covariance means they move in opposite directions. The magnitude of each value depends on the scale and variance of the columns involved, making covariance useful for understanding the absolute spread and co-movement of features rather than just the direction of their relationship.

By default the result is rendered as an annotated heatmap for quick visual inspection. Setting plot=False returns the raw covariance DataFrame, which is appropriate for tasks such as constructing a regularised precision matrix or performing principal component analysis manually.

Use this explorer when you need to understand the scale-sensitive relationships between features, or as a precursor to techniques that depend on the covariance structure of the data (e.g. PCA or Linear Discriminant Analysis).

Parameters

min_periods : integer, default=1
Minimum observations required per column pair to have a valid result.
delta_degree_of_freedom : integer, default=1
Delta degrees of freedom to use when calculating the covariance matrix. Only used if numeric_only is True.
numeric_only : boolean, default=True
If True, include only numeric columns in the calculation; otherwise include all columns.
plot : boolean, default=True
If True, the result will be plotted.

Methods

get_results(self, exploration_path: str, options: Dict[str, Any]) -> Dict[str, Any]

Defined on CovarianceMatrixExplorer

Load and return the saved covariance result for the frontend.

Parameters

exploration_path : str
Path to the JSON file saved by save_notebook.
options : Dict[str, Any]
Rendering options from the frontend (unused).

Returns

Dict[str, Any]
Dictionary with keys "data" (Plotly JSON string when plotting, or nested dict of the covariance matrix otherwise), "type" ("plotly_json" when plotting, or "tabular" otherwise), and "config" (empty dict when plotting, or {"orient": "dict"} otherwise).

launch_exploration(self, dataset: 'DashAIDataset', explorer_info: DashAI.back.dependencies.database.models.Explorer) -> Any

Defined on CovarianceMatrixExplorer

Compute a covariance matrix and optionally render it as a Plotly heatmap.

Parameters

dataset : DashAIDataset
The dataset whose columns will be used for covariance computation.
explorer_info : Explorer
The explorer database record used for the plot title and column count.

Returns

Any
A plotly.graph_objs.Figure heatmap when self.plot is True, or a pandas.DataFrame containing the covariance matrix when self.plot is False.

save_notebook(self, notebook_info: DashAI.back.dependencies.database.models.Notebook, explorer_info: DashAI.back.dependencies.database.models.Explorer, save_path: 'Path', result: Any) -> str

Defined on CovarianceMatrixExplorer

Save the covariance result to a JSON file on disk.

Parameters

notebook_info : Notebook
The notebook database record (unused).
explorer_info : Explorer
The explorer record used for filename generation.
save_path : Path
Directory where the file will be saved.
result : Any
The result returned by launch_exploration — either a plotly.graph_objs.Figure or a pandas.DataFrame.

Returns

str
The path of the saved JSON file as a POSIX string.

get_metadata(cls) -> Dict[str, Any]

Defined on BaseExplorer

Get metadata for the explorer, used by the DashAI frontend.

Returns

Dict[str, Any]
Dictionary containing display name, description, image preview path, category, icon, color, allowed dtypes, restricted dtypes, and input cardinality constraints.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

prepare_dataset(self, loaded_dataset: 'DashAIDataset', columns: List[Dict[str, Any]]) -> 'DashAIDataset'

Defined on BaseExplorer

Prepare the dataset by selecting only the columns needed for this exploration.

Parameters

loaded_dataset : DashAIDataset
The full dataset loaded from storage.
columns : List[Dict[str, Any]]
List of column descriptor dicts, each containing at least "columnName". Optional keys: "id", "valueType", "dataType".

Returns

DashAIDataset
Dataset restricted to the requested columns.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.

Parameters

raw_data : dict
A dictionary with the data provided by the user to initialize the model.

Returns

dict
A validated dictionary with the necessary objects.

validate_columns(cls, explorer_info: DashAI.back.dependencies.database.models.Explorer, column_spec: Dict[str, Dict[str, str]]) -> bool

Defined on BaseExplorer

Validate that the selected columns satisfy the explorer's constraints.

Parameters

explorer_info : Explorer
The database record for the explorer instance, including the selected columns.
column_spec : Dict[str, Dict[str, str]]
A mapping from column name to a dict with at least a "type" key describing the column's data type.

Returns

bool
True if all column constraints are satisfied, False otherwise.

validate_parameters(cls, params: Dict[str, Any]) -> bool

Defined on BaseExplorer

Validate explorer parameters against the explorer's schema.

Parameters

params : Dict[str, Any]
The configuration parameters to validate.

Returns

BaseExplorerSchema
The validated and parsed schema instance. Subclasses that override this method may return a bool to indicate pass/fail without returning the model instance.