Selection Matrix Helper

GitHub Link to Code.

Matrix operations helper for feature selection system.

Provides efficient matrix construction directly with proper shape calculation, memory management, and frame mapping instead of collecting and merging matrices.

class mdxplain.pipeline.helper.selection_matrix_helper.SelectionMatrixHelper

Helper class for efficient matrix construction from selection data.

Builds matrices directly with correct shape. Supports both regular arrays and memory-mapped files for large datasets.

static build_selection_matrix(pipeline_data: PipelineData, feature_selector_name: str, data_selector_name: str | None = None, build_frame_mapping: bool = False) Tuple[np.ndarray, Dict[int, Tuple[int, int]] | None]

Build selection matrix with efficient memory usage and caching.

Uses caching when use_memmap=True to avoid rebuilding identical matrices.

Parameters

pipeline_dataPipelineData

Pipeline data object containing all data

feature_selector_namestr

Name of the feature selection

data_selector_namestr, optional

Name of data selector for frame filtering

build_frame_mappingbool, default=False

Whether to build and return row-to-frame mapping.

Returns

Tuple[np.ndarray, Dict[int, Tuple[int, int]] or None]

Complete matrix and optional frame mapping.