Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rasa test nlu: use the correct number of examples #5568

Merged
merged 2 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/5426.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `rasa test nlu` plotting when using multiple runs.
4 changes: 3 additions & 1 deletion rasa/nlu/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,9 @@ def compare_nlu(
percent_string = f"{percentage}%_exclusion"

_, train = train.train_test_split(percentage / 100)
training_examples_per_run.append(len(train.training_examples))
# only count for the first run and ignore the others
if run == 0:
training_examples_per_run.append(len(train.training_examples))

model_output_path = os.path.join(run_path, percent_string)
train_split_path = os.path.join(model_output_path, "train")
Expand Down
15 changes: 15 additions & 0 deletions tests/nlu/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ def config_path() -> Text:
).name


@pytest.fixture(scope="session")
def config_path_duplicate() -> Text:
return write_file_config(
{
"language": "en",
"pipeline": [
{"name": "WhitespaceTokenizer"},
{"name": "CRFEntityExtractor", EPOCHS: 1, RANDOM_SEED: 42},
{"name": "CountVectorsFeaturizer"},
{"name": "EmbeddingIntentClassifier", EPOCHS: 1, RANDOM_SEED: 42},
],
}
).name


@pytest.fixture()
def pretrained_embeddings_spacy_config() -> RasaNLUModelConfig:
return RasaNLUModelConfig(
Expand Down
6 changes: 4 additions & 2 deletions tests/nlu/test_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,10 @@ def test_get_evaluation_metrics(
assert NO_ENTITY not in report


def test_nlu_comparison(tmpdir, config_path):
configs = [config_path, config_path]
def test_nlu_comparison(tmpdir, config_path, config_path_duplicate):
# the configs need to be at a different path, otherwise the results are
# combined on the same dictionary key and cannot be plotted properly
configs = [config_path, config_path_duplicate]

output = tmpdir.strpath
compare_nlu_models(
Expand Down