But this is extremely slow and it seems like it would take most of a day to complete executing.

What is the correct way to get batch predictions for a test dataset with a TabularLearner in fastai v2? If anyone can point me in the right direction, I’d really appreciate it!

Thanks for your reply. However, I have a question. For the new dataset when we do not know the output (label column) of the data, then the predictions for the label part throws None. I think something is wrong here. Because with standard predict method we get the probability+label (for example “yes”/“no”). What do you think?

@henry090: learn.predict() and learn.get_preds() give different outputs. learn.predict() returns predicted class names, predicted class index and predicted probabilities. learn.get_preds() on the other hand returns predicted probabilities and true classes. So for a new dataset without labels, it’s correct that the second output returns None.

You can then take the predicted probabilities, get the predicted class index using argmax and the corresponding class name by indexing into dls.vocab (or dls.vocab[1] in NLP).

@stefan-ai@muellerzr Both answers are very helpful! dls.vocab for column names and with_decoded=True which will append labels as well! Thanks very much!