[英]How to get the predictions of the textdata in fasttext python?
I am building a supervised model for text classification in fasttext.我正在构建一个受监督的 model 用于 fasttext 中的文本分类。
To predict the output of a particular string we can use this in python要预测特定字符串的 output,我们可以在 python 中使用它
model.predict("Why not put knives in the dishwasher?")
But how to get the predictions for the whole test set by a python command?但是如何通过 python 命令获得整个测试集的预测? In the commandline it can be done like this
在命令行中可以这样做
./fasttext predict <path to model> <path to test file> k > <path to prediction file>
I found the solution我找到了解决方案
def predict(row):
return model.predict(row['input'])
test['predictions'] = test.apply(predict,axis=1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.