class.bag function, majority vote