Is there a smart list/dictionary comprehension way of getting the intended output below give the following:
import numpy as np
freq_mat = np.random.randint(2,size=(4,5));
tokens = ['a', 'b', 'c', 'd', 'e'];
labels = ['X', 'S', 'Y', 'S'];
The intended output for freq_mat
array([[1, 0, 0, 1, 1],
[0, 0, 0, 0, 1],
[1, 0, 1, 1, 0],
[0, 1, 0, 0, 0]])
should like the following:
[({'a': True, 'b': False, 'c': False, 'd': True, 'e': True}, 'X'),
({'a': False, 'b': False, 'c': False, 'd': False, 'e': True}, 'S'),
({'a': True, 'b': False, 'c': True, 'd': True, 'e': False}, 'Y'),
({'a': False, 'b': True, 'c': False, 'd': False, 'e': False}, 'S')]