Skip to content

Commit 00e4824

Browse files
committed
Add confmat filename check
1 parent fdc762d commit 00e4824

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

rasa_nlu/evaluate.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -361,21 +361,22 @@ def evaluate_intents(intent_results,
361361
# log and save misclassified samples to file for debugging
362362
collect_nlu_errors(intent_results, errors_filename)
363363

364-
from sklearn.metrics import confusion_matrix
365-
from sklearn.utils.multiclass import unique_labels
366-
import matplotlib.pyplot as plt
367-
368-
cnf_matrix = confusion_matrix(targets, predictions)
369-
labels = unique_labels(targets, predictions)
370-
plot_confusion_matrix(cnf_matrix, classes=labels,
371-
title='Intent Confusion matrix',
372-
out=confmat_filename)
373-
plt.show()
374-
375-
plot_intent_confidences(intent_results,
376-
intent_hist_filename)
377-
378-
plt.show()
364+
if confmat_filename:
365+
from sklearn.metrics import confusion_matrix
366+
from sklearn.utils.multiclass import unique_labels
367+
import matplotlib.pyplot as plt
368+
369+
cnf_matrix = confusion_matrix(targets, predictions)
370+
labels = unique_labels(targets, predictions)
371+
plot_confusion_matrix(cnf_matrix, classes=labels,
372+
title='Intent Confusion matrix',
373+
out=confmat_filename)
374+
plt.show()
375+
376+
plot_intent_confidences(intent_results,
377+
intent_hist_filename)
378+
379+
plt.show()
379380

380381
predictions = [
381382
{

0 commit comments

Comments
 (0)