lib5c.contrib.iced.balancing module¶
Module for interfacing with the external iced
Python package, which provides
access to the ICED matrix balancing algorithm.
-
lib5c.contrib.iced.balancing.
iced_balance_matrix
(matrix, max_iter=3000, eps=0.0001, norm='l1', imputation_size=0)[source]¶ Convenience function wrapping the
ICE_normalization
function from the externaliced
Python package, which balances a counts matrix using the ICE algorithm.- Parameters
matrix (np.ndarray) – The counts matrix to balance.
max_iter (int) – The maxiumum number of iterations to try.
eps (float) – The relative size of error before declaring convergence.
norm ({'l1', 'l2'}) – What norm to use as a distance measure.
imputation_size (int) – Pass an int greater than 0 to replace NaN’s in the matrix with a local median approximation. Pass 0 to skip imputation.
- Returns
The first element of the tuple is the balanced matrix. The second element is the bias vector.
- Return type
Tuple[np.ndarray, np.ndarray]