metbit._native
_native.py - Compute-backend dispatcher for metbit large-scale kernels.
import metbit._nativeFunctions
native_available()
Return True when the compiled C extension is active.
gpu_available()
Return True when a CUDA-capable GPU backend is available.
backend_info()
Return a dict describing the active compute backends.
pearson_columns(data, anchor_index: int, chunk_size: int=_DEFAULT_CHUNK, n_jobs: int=_N_JOBS)
Pearson r between one column and all other columns of a 2D matrix.
Backend auto-selected based on dataset size and available hardware:
GPU (cupy/torch) n*p > LARGE_THRESH and GPU available C + OpenMP (parallel) n*p > SMALL_THRESH and C ext available C single-threaded n*p <= SMALL_THRESH and C ext available multiprocessing + NumPy C ext absent, n_jobs > 1 chunked NumPy (1 process) absolute fallback
Parameters
dataarray-like, shape (n_samples, n_features)anchor_indexintchunk_sizeintFeature chunk for chunked NumPy / multiprocessing paths.
n_jobsintWorker processes for the multiprocessing path.
column_variances(data, chunk_size: int=_DEFAULT_CHUNK, n_jobs: int=_N_JOBS)
Per-column sample variance for feature pre-selection.
Auto-dispatches to GPU, C extension, multiprocessing, or NumPy using the same hierarchy as pearson_columns.
Parameters
dataarray-like, shape (n_samples, n_features)chunk_sizeintn_jobsintReturns
np.ndarray of shape (n_features,), float64
vip_scores(t_scores: np.ndarray, x_weights: np.ndarray, y_loadings: np.ndarray)
Vectorised VIP scores.
VIP[i] = sqrt( p * sum_h( S[h] * (w[i,h]/||w[:,h]||)^2 ) / sum(S) ) where S[h] = ||t[:,h]||^2 * q[h]^2.
Parameters
t_scores(n_samples, n_components) float64x_weights(n_features, n_components) float64y_loadings(n_components,) or (1, n_components) float64Returns
np.ndarray of shape (n_features,), float64