Features.permute¶
- Features.permute(order=None, *, useLog=None)¶
Permute the indexing of the features.
Change the arrangement of features in the object. A specific permutation can be provided as the
order
argument. Iforder
is None, the permutation will be random. Note: a random permutation may be the same as the current permutation.- Parameters:
order (list, None) – A list of identifiers indicating the new permutation order. If None, the permutation will be random.
useLog (bool, None) – Local control for whether to send object creation to the logger. If None (default), use the value as specified in the “logger” “enabledByDefault” configuration option. If True, send to the logger regardless of the global option. If False, do NOT send to the logger, regardless of the global option.
Notes
Random permutation relies on python’s random.shuffle() which may not be sufficiently random for large number of features. See random.shuffle()’s documentation.
See also
Examples
>>> nimble.random.setSeed(42) >>> lst = [[1, 2, 3, 4], ... [1, 2, 3, 4], ... [1, 2, 3, 4], ... [1, 2, 3, 4]] >>> X = nimble.data(lst) >>> X.features.permute() >>> X <Matrix 4pt x 4ft 0 1 2 3 ┌─────────── 0 │ 3 2 4 1 1 │ 3 2 4 1 2 │ 3 2 4 1 3 │ 3 2 4 1 >
Permute with a list of identifiers.
>>> lst = [['home', 81, 3], ... ['gard', 98, 10], ... ['home', 14, 1], ... ['home', 11, 3]] >>> cols = ['dept', 'ID', 'quantity'] >>> orders = nimble.data(lst, featureNames=cols) >>> orders.features.permute(['ID', 'quantity', 'dept']) >>> orders <DataFrame 4pt x 3ft ID quantity dept ┌─────────────────── 0 │ 81 3 home 1 │ 98 10 gard 2 │ 14 1 home 3 │ 11 3 home >
Keywords: reorder, rearrange, shuffle