首页 > 解决方案 > 从 rasa 模型的输出中删除意图排名

问题描述

我已经开发了一个 rasa 意图分类模型,它显示了训练数据中的正确意图和实体,但此外,它还显示了与所有其他意图的意图排名,我不希望显示出来,任何人都可以帮助我从我的输出中删除它感谢您的帮助.......模型的代码是......

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

# from rasa_nlu.converters import load_data
from rasa_nlu.training_data import load_data

from rasa_nlu.config import RasaNLUModelConfig
#from rasa_nlu.config import RasaNLUConfig
from rasa_nlu.model import Trainer, Metadata, Interpreter
from rasa_nlu import config

def train (data, config_file, model_dir):
     training_data = load_data(data)
     configuration = config.load(config_file)
     trainer = Trainer(configuration)
     trainer.train(training_data)
     model_directory = trainer.persist(model_dir, fixed_model_name = 'chat')

def run():
    interpreter = Interpreter.load('./models/nlu/default/chat')
    print(interpreter.parse('buy a pendrive from amazon'))
    #print(interpreter.parse(u'What is the reivew for the movie Die Hard?'))

if __name__ == '__main__':
     #train('./data/testData.json', './config/config.yml', './models/nlu')
     run()

用于在训练和注释 run() 之前删除数据,反之亦然 ,在运行后输出

只想删除意图排名

标签: pythonmachine-learningnlprasa-nlu

解决方案


也许尝试:

def run():
    interpreter = Interpreter.load('./models/nlu/default/chat')
    parseResult = interpreter.parse('buy a pendrive from amazon')
    parseResult.pop("intent_ranking", None)
    print(parseResult)
    #print(interpreter.parse(u'What is the reivew for the movie Die Hard?'))

这是未经测试的,但应该从他的 dict 中删除该密钥。http://docs.python.org/library/stdtypes.html#dict.pop


推荐阅读