Copied clustering stuff from sklearn