An Optimisation-based Framework for Data Classification with Multiple Groups