Exemplo n.º 1
0
    def test_plot_confusion_matrix_ticklabels_false(self):
        """
        Test of the `plot_confusion_matrix` function.

        Check with the `ticklabels` option set to False.
        """
        ax = bplt.plot_confusion_matrix(self.y_true_matrix,
                                        self.y_pred_matrix,
                                        ticklabels=False)
        return ax.figure
Exemplo n.º 2
0
    def test_plot_confusion_matrix_ticklabels_n_labels(self):
        """
        Test of the `plot_confusion_matrix` function.

        Check with the `ticklabels` option and print every 2 labels.
        """
        ax = bplt.plot_confusion_matrix(self.y_true_matrix,
                                        self.y_pred_matrix,
                                        ticklabels=2)
        return ax.figure
Exemplo n.º 3
0
    def test_plot_confusion_matrix_stats_fscore(self):
        """
        Test of the `plot_confusion_matrix` function.

        Check with the `stats` option with categorical values.
        """
        ax = bplt.plot_confusion_matrix(self.y_true_matrix_cat,
                                        self.y_pred_matrix_cat,
                                        stats='f1-score')
        return ax.figure
Exemplo n.º 4
0
    def test_plot_confusion_matrix_ticklabels_cat(self):
        """
        Test of the `plot_confusion_matrix` function.

        Use categorical predictions.
        """
        ax = bplt.plot_confusion_matrix(self.y_true_matrix_cat,
                                        self.y_pred_matrix_cat)

        return ax.figure
Exemplo n.º 5
0
    def test_plot_confusion_matrix_stats_acc(self):
        """
        Test of the `plot_confusion_matrix` function.

        Check with the `stats` option.
        """
        ax = bplt.plot_confusion_matrix(self.y_true_matrix,
                                        self.y_pred_matrix,
                                        stats='accuracy')
        return ax.figure
Exemplo n.º 6
0
    def test_plot_confusion_matrix_stats_prec(self):
        """
        Test of the `plot_confusion_matrix` function.

        Check with the `stats` option with precision for all classes.
        """
        ax = bplt.plot_confusion_matrix(self.y_true_matrix,
                                        self.y_pred_matrix,
                                        stats='precision')
        return ax.figure
Exemplo n.º 7
0
    def test_plot_confusion_matrix_normalize(self):
        """
        Test of the `plot_confusion_matrix` function.

        Check with the `normalize` option.
        """
        ax = bplt.plot_confusion_matrix(self.y_true_matrix,
                                        self.y_pred_matrix,
                                        normalize='all')
        return ax.figure
Exemplo n.º 8
0
    def test_plot_confusion_matrix_labels_filter(self):
        """
        Test of the `plot_confusion_matrix` function.

        Check with the `labels_filter` option.
        """
        ax = bplt.plot_confusion_matrix(self.y_true_matrix,
                                        self.y_pred_matrix,
                                        labels_filter=[3, 1])
        return ax.figure
Exemplo n.º 9
0
    def test_plot_confusion_matrix_sample_weight(self):
        """
        Test of the `plot_confusion_matrix` function.

        Check with the `sample_weigth` option.
        """
        weights = range(1, len(self.y_true_matrix) + 1)
        ax = bplt.plot_confusion_matrix(self.y_true_matrix,
                                        self.y_pred_matrix,
                                        sample_weight=weights)
        return ax.figure
Exemplo n.º 10
0
    def test_plot_confusion_matrix_stats_error(self):
        """
        Test of the `plot_confusion_matrix` function.

        Check with the `stats` option when the key of the stat is wrong.
        """
        # Check the error message using a mock.
        with unittest.mock.patch('logging.Logger.error') as mock_logging:
            ax = bplt.plot_confusion_matrix(self.y_true_matrix_cat,
                                            self.y_pred_matrix_cat,
                                            stats='acc')
            mock_logging.assert_called_with(
                "Wrong key acc, possible values: "
                "['precision', 'recall', 'f1-score', 'support'].")
            return ax.figure
Exemplo n.º 11
0
 def test_plot_confusion_matrix(self):
     """
     Test of the `plot_confusion_matrix` function.
     """
     ax = bplt.plot_confusion_matrix(self.y_true_matrix, self.y_pred_matrix)
     return ax.figure