If my DataBlock has multiple inputs, what should I pass to "learn.predict"?

Given the below:

blocks = (
    TextBlock.from_df(text_cols='text', res_col_name='text', rules=[]),
    TextBlock.from_df(text_cols='text2', res_col_name='text2', trules=[]),

dblock = DataBlock(blocks=blocks, 
                   get_x=[ColReader('text'), ColReader('text2')], 

… when doing inference, how should I pass my two text items to learn.predict?

I think just a DataFrame row so long as it has a text and text2 column should befine?

inf_df = pd.DataFrame.from_dict([{'text': 'I really liked the movie', 'text2': 'The movie was great'}], orient='columns')


AssertionError: Expected an input of type in 
  - <class 'pandas.core.series.Series'>
  - <class 'str'>
  - <class 'list'>
  - <class 'fastcore.foundation.L'>
  - <class 'tuple'>
  - <class 'pathlib.Path'>
  - <class 'fastai2.text.data.TensorText'>
 but got <class 'pandas.core.frame.DataFrame'>

Try passing in the row, not the actual dataframe. (Looking at the first option you can see that’s something we can do, a Series)

1 Like

Yah that did it!

Thanks much!

1 Like