Unsupervised and supervised data classification via nonsmooth and global optimization