Search code examples
pythonnlpchatbotrasa-nlurasa-core

How to test a RASA model?


I'm trying to write my own chatbot with the RASA framework.
Right now I'm just playing around with it and I have the following piece of code for training purposes.

from rasa.nlu.training_data import load_data
from rasa.nlu.config import RasaNLUModelConfig
from rasa.nlu.model import Trainer
from rasa.nlu import config
training_data = load_data("./data/nlu.md")
trainer = Trainer(config.load("config.yml"))
interpreter = trainer.train(training_data)
model_directory = trainer.persist("./models/nlu",fixed_model_name="current")

Now, I read that if I wanted to test it I should do something like this.

from rasa.nlu.evaluate import run_evaluation
run_evaluation("nlu.md", model_directory)

But this code is not available anymore in rasa.nlu.evaluate nor in rasa.nlu.test!
What's the way, then, of testing a RASA model?


Solution

  • The module was renamed. Please import

    from rasa.nlu.test import run_evaluation
    

    Alternatively you now also do

    from rasa.nlu import test
    test_result = test(path_to_test_data, unpacked_model)
    
    intent_evaluation_report = test_result["intent_evaluation"]["report"]
    print(intent_evaluation_report)