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_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
nipals(x: np.ndarray, y: np.ndarray, tol: float=1e-10, max_iter: int=1000)
NIPALS-PLS1. Returns (w, u, c, t).
Dispatches to the C extension when available; falls back to pure NumPy.
Parameters
x(n, p) float64y(n,) float64tolconvergence tolerancemax_itermaximum iterationsReturns
w(p,) weightsu(n,) y-scorescfloat y-weightt(n,) x-scoresscale_transform(X: np.ndarray, mean: np.ndarray, s: np.ndarray)
Element-wise (X - mean) / s.
s is std for standard scaling or sqrt(std) for pareto scaling. Dispatches to the C extension when available; otherwise NumPy broadcast.
Parameters
X(n, p) float64mean(p,) float64 column meanss(p,) float64 divisors (std or sqrt(std))Returns
np.ndarray (n, p) float64
xcorr_max_shift(template: np.ndarray, query: np.ndarray, max_shift: int)
Find the integer shift in [-max_shift, max_shift] maximising cross-correlation.
Parameters
template(n,) float64 reference spectrum windowquery(n,) float64 sample spectrum windowmax_shiftint half-width of the shift search rangeReturns
(shift, corr) – best integer shift and its cross-correlation value
pqn_median_quotient(sample: np.ndarray, reference: np.ndarray)
Median of (sample / reference) over non-zero reference entries.
Parameters
sample(n,) float64reference(n,) float64Returns
float – median quotient (1.0 if no valid entries)