From https://github.com/zygmuntz/nonlinear-vowpal-wabbit/blob/master/split.py