giddy.util.shuffle_matrix¶
- giddy.util.shuffle_matrix(X, ids)[source]¶
Random permutation of rows and columns of a matrix
- Parameters:
- Xarray
(k, k), array to be permutated.
- idsarray
range (k, ).
- Returns:
- Xarray
(k, k) with rows and columns randomly shuffled.
Examples
>>> import numpy as np >>> from giddy.util import shuffle_matrix >>> X=np.arange(16) >>> X.shape=(4,4) >>> np.random.seed(10) >>> shuffle_matrix(X,list(range(4))) array([[10, 8, 11, 9], [ 2, 0, 3, 1], [14, 12, 15, 13], [ 6, 4, 7, 5]])