Reputation: 2528
I have defined databunch as
data = (TabularList.from_df(train_df, path='./', cont_names=cont_names, procs=procs)
.split_by_idx(list(range(500,3000)))
.label_from_df(cols=dep_var)
.add_test(test, label=0)
.databunch())
After training i am
p = learn3.get_preds()
len(p[1])
o/p is 2500 which is correct as
.split_by_idx(list(range(500,3000)))
this is 2500 numbers
for index in range(len(test_df)):
predictions = learn3.predict(test_df.iloc[index])
predictions = predictions[1].tolist()
print(index)
It will take really huge amount of time. I want to pass test_df and get the predictions as was as
p = learn3.get_preds()
How can i do that ?
.split_by_idx(list(range(500,3000)))
Do we have way to replace this and pass data from other file ?
Upvotes: 5
Views: 2493
Reputation: 3062
I have struggled with this for a while. The best method I have found is to do the following:
test_dl = learn.dls.test_dl(test_data) # Create a test dataloader
learn.get_preds(dl = test_dl) # Make predictions on it
Upvotes: 4
Reputation: 609
you can use fastai learner's add_test()
method to replace the learner's original test set with your data. Alternatively you can also use learn.data.test_dl = new_df
to achieve the same and then use get_preds()
to get the predictions
Upvotes: 1