All the ways to do one-hot encoding

Brilliant! Not sure what permutedims does in case x is multidimensional, so maybe the following is slightly more general:

unique(x) .== reshape(x, (1, size(x)…))
2 Likes