假设Humpty Dumpty是在给定的特定模型下训练的文本,属于多文本分类模型中称为卡通人物的类别。
model.predict_proba([Invoice_parameter])*100
# gives the probability of belongings to specific class.但是为什么我可以检索到那个类的概率命中的文本。
例如,
Invoice_parameter= input() ---- on the fly input
"Humpty Dumpty sat on the wall"
model.predict_proba([Invoice_parameter])*100 我得到了字符类的概率为99.98 (四舍五入到小数点后两位),但我还需要检索文本Humpty Dumpty。
确切地说,我正在寻找指向模型所标识的类的文本。
“矮子坐在墙上”
当上面的语句提供给预先训练/保存的模型时,它将返回Character形式的类输出。
此外,我想要的文本部分,这是为各自的班级训练。假设Humpty Dumpty是在Character类下训练的。
这里我使用的是预训练模型,Invoice_parameter是我像Humpty Dumpty sat on the wall一样传递的输入
import pandas as pd
Class_Predictive_Prob=pd.DataFrame(model.predict_proba([Invoice_parameter])*100, columns=model.classes_)
print("Class with predictive probability",Class_Predictive_Prob.max(axis=0))
Output for Multi-Class Text Classification problem
_________
Class with predictive probability
Movies 0.000015
Character 99.980123
Drama 0.000008
So on..我正在寻找输出,如下所示:
Class followed by the probability hit and the text part giving that hit
Output for Multi-Class Text Classification problem
_________
Class with predictive probability角色99.980123矮胖的笨蛋
发布于 2019-08-14 18:53:18
您实现的内容听起来像是文本分类(对整个文本进行分类),但是您想要的内容听起来像是实体识别(在令牌级别进行分类)。您仍然可以构建一个同时执行这两个任务的模型(多任务学习),但您需要为两个任务都添加标签数据(不仅在文本上,而且在令牌级上也需要标签)。
https://stackoverflow.com/questions/57490868
复制相似问题