Term frequency inverse frequency weighting for train and test datasets