This is going to crash when given a sparse matrix `X` (the intended input format). Also, the `{0, 1}` syntax is not supported in Python 2.6, I believe.