Memory efficient BoW classifier