If we limit this to < 32 initial classes (which is very reasonable!), you can use:
```python
def _uint_bits():
y_decoded = np.unpackbits(y_coded.astype('>u4').view('u1')).reshape((-1, 32))[:, -n_classes:][:, ::-1]
```
though that's a bit obfuscated.

Where sparse is necessary, can do something like:
```python
y_coded = y_coded.astype(np.uint32)
indices = array.array('i')
indptr = array.array('i', [0])
mask = np.array(1, dtype=np.uint32)
for i in range(n_classes):
    indices.extend(np.flatnonzero(mask & y_coded))
    indptr.append(len(indices))
    mask *= 2

data = np.empty(len(indices), dtype=np.uint8)
data.fill(1)
y_decoded = sp.csc_matrix((data, indices, indptr), shape=(n_samples, n_classes))
```
(or for `n_samples >> 2**n_classes`, you could binary encode `arange(2**n_classes)`, transform to csr, then extract rows `y_coded`.)