Completed multinomial classify function.