Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)

I'm trying to build a supervised model for text arrangement/classification in fasttext. 

To predict the yield of a specific string we can utilize this in python 

model.predict("Why not put knives in the dishwasher?")

In any case, how to get the predictions for the entire test set by a python command? In the commandline it very well may be done like this

./fasttext predict <path to model> <path to test file> k > <path to prediction file>

1 Answer

0 votes
by (26.4k points)

Try the following code:

def predict(row):

    return model.predict(row['input'])

test['predictions'] = test.apply(predict,axis=1)

Wanna become a Python expert? Come and join the python certification course and get certified.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...