Hi,
I’m trying to play on Kaggle using the lesson3-imdb notebook, but I’m confused by the final prediction step.
In lesson3-imdb, we end up with a learn.predict("I really loved that movie, it was awesome!")
for a text_classifier_learner trained with a TextClasDataBunch.
I want to apply predict on all the rows of the test dataset of my databunch, but I’m not sure how to do so. The test ds appears to be of type fastai.data_block.LabelList
I also noticed that the test_ds object itself has a predict method, which doesn’t make sense.
Any idea how to predict all rows of a test databunch using the text_classifier_learning predict method ?
Related doc:
- https://docs.fast.ai/text.learner.html#text_classifier_learner
- https://docs.fast.ai/text.data.html#TextClasDataBunch
- https://docs.fast.ai/data_block.html#LabelList
Code:
data = TextClasDataBunch.from_csv('data', 'train.csv', label_cols='target')
data.save()
data = TextClasDataBunch.load('data', bs=50)
learn = text_classifier_learner(data, drop_mult=0.5)
learn.lr_find()
learn.recorder.plot()
learn.fit_one_cycle(1, max_lr=slice(1e-3, 1e-1), moms=(0.8,0.7))
learn.save('first')
data_clas = TextClasDataBunch.from_csv('data', 'train.csv', test='test.csv', label_cols='target')
# predict ??? following command doesn't work
learn.predict(data_clas.test_ds)