FastAI 1.0 Confusion about getting prediction from language classifier

Create data object and fit model

Trying to get the model to predict on the validation set. Expected 93.8% accuracy but get 1.0%

At the same time learner.validate seems to produce the right number:

Now I am trying really hard to reproduce the 93.9% accuracy indicated by the training print out and get.validate. I tried to loop through each row in the validation df frame get the prediction individually.
However, the result accuracy still differes from 93.9%


  1. How do I get predictions from learn object properly?
  2. Why are accuracy numbers all over the place between learn.get_preds() learn.validate() and
    training print out ?
  3. How do I get predictions from test data in the original order from TextClasDataBunch 's test dataset
    (No random order)

Note that for 1, learn.predict gives you the index of the class in the second position of the tuple (so there is no need to do an argmax).
For 2, I can’t say since I don’t know your function accuracy_score. Not that learn.validate() gave you the same results as during training.
For 3, use ordered=True in learn.get_preds().

accuracy_score is imported from sklearn.metrics