From 6105522361b652477bbc60277454f3f1dea03bb3 Mon Sep 17 00:00:00 2001 From: Angela Lin Date: Sun, 1 Mar 2020 15:53:26 -0500 Subject: [PATCH] Change colors of confusion matrix to shades of blue and change the axis order to match scikit-learn's (#426) * changing colors of heatmap * changelog * update output labels * update changelog * actually fixing columns to make it the same order as sklearn's * moving reversal of cols to data generation step instead --- docs/source/changelog.rst | 1 + evalml/automl/pipeline_search_plots.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 45e011a786..95cd8ca352 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -8,6 +8,7 @@ Changelog * Add CatBoost (gradient-boosted trees) classification and regression components and pipelines :pr:`247` * Added Tuner abstract base class :pr:`351` * Added n_jobs as parameter for AutoClassificationSearch and AutoRegressionSearch :pr:`403` + * Changed colors of confusion matrix to shades of blue and updated axis order to match scikit-learn's :pr:`426` * Fixes * Fixed ROC and confusion matrix plots not being calculated if user passed own additional_objectives :pr:`276` * Changes diff --git a/evalml/automl/pipeline_search_plots.py b/evalml/automl/pipeline_search_plots.py index 8b6ddaa126..94203d69b2 100644 --- a/evalml/automl/pipeline_search_plots.py +++ b/evalml/automl/pipeline_search_plots.py @@ -186,7 +186,10 @@ def get_confusion_matrix_data(self, pipeline_id): confusion_matrix_data = [] for fold in cv_data: - confusion_matrix_data.append(fold["all_objective_scores"]["Confusion Matrix"]) + conf_mat = fold["all_objective_scores"]["Confusion Matrix"] + # reverse columns in confusion matrix to change axis order to match sklearn's + conf_mat = conf_mat.iloc[:, ::-1] + confusion_matrix_data.append(conf_mat) return confusion_matrix_data def generate_confusion_matrix(self, pipeline_id, fold_num=None): @@ -205,15 +208,17 @@ def generate_confusion_matrix(self, pipeline_id, fold_num=None): conf_mat = data[fold_num] labels = conf_mat.columns + reversed_labels = labels[::-1] layout = go.Layout(title={'text': 'Confusion matrix of
{} w/ ID={}'.format(pipeline_name, pipeline_id)}, - xaxis={'title': 'Predicted Label', 'tickvals': labels}, - yaxis={'title': 'True Label', 'tickvals': labels}) - figure = go.Figure(data=go.Heatmap(x=labels, y=labels, z=conf_mat, + xaxis={'title': 'Predicted Label', 'type': 'category', 'tickvals': labels}, + yaxis={'title': 'True Label', 'type': 'category', 'tickvals': reversed_labels}) + figure = go.Figure(data=go.Heatmap(x=labels, y=reversed_labels, z=conf_mat, hovertemplate='True: %{y}' + '
Predicted: %{x}' + '
Number of times: %{z}' + - ''), # necessary to remove unwanted trace info + '', # necessary to remove unwanted trace info + colorscale='Blues'), layout=layout) return figure