2

I am working on a text model which predicts which category the text belongs to (multiple category model). There are two files train.csv- having text samples and labels and test.csv - having text samples only.

I am using the fast.ai library and my learner is all set up and fine-tuned. Now I need to apply my learner on the test.csv file as done in Cell [38] in this Kaggle Notebook

preds, target = learn.get_preds(DatasetType.Test, ordered=True)
labels = preds.numpy()

Note: Fast.ai v2 is not compatible with v1

Since this code is written in fast.ai v1, I need to convert it to v2 as the above code does not run giving the error NameError: name 'DatasetType' is not defined. How do I make the model run on the test file? I have seen a lot of examples where the exact code ran nicely, however that was in v1.

Possible solutions:

  1. Try to define DatasetType.Test in some way, but that may not be happy with v2
  2. Keep predicting and storing the results simultaneously. I tried to do the following, but the kernel died!
    predicted = []
    real = []
    for elem in range(test_df.shape[0]):
        row, clas, probs = learn_classifier.get_preds(test_df.iloc[elem])
        # append to the lists

0 Answers0