use unique from sklearn backports (return_inverse)