/
You are viewing the documentation for metbit 9.0.0. Change release context

metbit._native

_native.py - Compute-backend dispatcher for metbit large-scale kernels.

import metbit._native

Functions

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_indexint
chunk_sizeint

Feature chunk for chunked NumPy / multiprocessing paths.

n_jobsint

Worker 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_sizeint
n_jobsint

Returns

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) float64
x_weights(n_features, n_components) float64
y_loadings(n_components,) or (1, n_components) float64

Returns

np.ndarray of shape (n_features,), float64

Source

metbit/_native.py at v9.0.0
Project downloadsPyPI and GitHub measure different distribution channels. Statistics refresh daily.

Counts are distribution activity, not unique users. GitHub source archives and Git clones are not included. Sources: PyPI Stats, Pepy, ClickPy, and GitHub Releases.

metbit 9.0.0 documentation