def test_color_sequence_bounds(self):
        """
        Test color sequence out of bounds value error
        """
        with self.assertRaises(YellowbrickValueError):
            color_sequence('RdBu', 18)

        with self.assertRaises(YellowbrickValueError):
            color_sequence('RdBu', 2)
示例#2
0
    def test_color_sequence_bounds(self):
        """
        Test color sequence out of bounds value error
        """
        with self.assertRaises(YellowbrickValueError):
            cmap = color_sequence('RdBu', 18)

        with self.assertRaises(YellowbrickValueError):
            cmap = color_sequence('RdBu', 2)
    def test_color_sequence_bounds(self):
        """
        Test color sequence out of bounds value error
        """
        with pytest.raises(YellowbrickValueError):
            color_sequence("RdBu", 18)

        with pytest.raises(YellowbrickValueError):
            color_sequence("RdBu", 2)
示例#4
0
    def __init__(self,
                 model,
                 ax=None,
                 sample_weight=None,
                 percent=False,
                 classes=None,
                 encoder=None,
                 cmap="YlOrRd",
                 fontsize=None,
                 is_fitted="auto",
                 force_model=False,
                 **kwargs):
        super(ConfusionMatrix, self).__init__(model,
                                              ax=ax,
                                              classes=classes,
                                              encoder=encoder,
                                              is_fitted=is_fitted,
                                              force_model=force_model,
                                              **kwargs)

        # Visual parameters
        self.fontsize = fontsize
        self.cmap = color_sequence(cmap)
        self.cmap.set_under(color=CMAP_UNDERCOLOR)
        self.cmap.set_over(color=CMAP_OVERCOLOR)

        # Estimator parameters
        self.percent = percent
        self.sample_weight = sample_weight

        # Used to draw diagonal line for predicted class = true class
        self._edgecolors = []
 def test_color_sequence_default(self):
     """
     Assert the default color sequence is RdBu
     """
     cmap = color_sequence()
     self.assertEqual(cmap.name, "RdBu")
     self.assertEqual(cmap.N, 11)
    def __init__(self,
                 estimator,
                 ax=None,
                 classes=None,
                 cmap="YlOrRd",
                 support=None,
                 encoder=None,
                 is_fitted="auto",
                 force_model=False,
                 **kwargs):
        super(ClassificationReport, self).__init__(estimator,
                                                   ax=ax,
                                                   classes=classes,
                                                   encoder=encoder,
                                                   is_fitted=is_fitted,
                                                   force_model=force_model,
                                                   **kwargs)

        self.support = support
        self.cmap = color_sequence(cmap)
        self.cmap.set_over(color=CMAP_OVERCOLOR)
        self.cmap.set_under(color=CMAP_UNDERCOLOR)
        self._displayed_scores = [key for key in SCORES_KEYS]

        if support not in {None, True, False, "percent", "count"}:
            raise YellowbrickValueError(
                "'{}' is an invalid argument for support, use None, True, "
                "False, 'percent', or 'count'".format(support))

        if not support:
            self._displayed_scores.remove("support")
示例#7
0
 def test_color_sequence_default(self):
     """
     Assert the default color sequence is RdBu
     """
     cmap = color_sequence()
     self.assertEqual(cmap.name, "RdBu")
     self.assertEqual(cmap.N, 11)
 def test_color_sequence_default(self):
     """
     Assert the default color sequence is RdBu
     """
     cmap = color_sequence()
     assert cmap.name == "RdBu"
     assert cmap.N == 11
 def test_color_sequence(self):
     """
     Ensure the color sequence returns listed colors.
     """
     for name, ncols in SEQUENCES.items():
         for n in ncols.keys():
             cmap = color_sequence(name, n)
             self.assertEqual(name, cmap.name)
             self.assertEqual(n, cmap.N)
示例#10
0
 def test_color_sequence(self):
     """
     Ensure the color sequence returns listed colors.
     """
     for name, ncols in SEQUENCES.items():
         for n in ncols.keys():
             cmap = color_sequence(name, n)
             self.assertEqual(name, cmap.name)
             self.assertEqual(n, cmap.N)
 def test_color_sequence(self):
     """
     Ensure the color sequence returns listed colors.
     """
     for name, ncols in SEQUENCES.items():
         for n in ncols.keys():
             cmap = color_sequence(name, n)
             assert name == cmap.name
             assert n == cmap.N
示例#12
0
 def __init__(self,
              model,
              test_data,
              y_true,
              classes,
              name,
              path_to_save="./"):
     self.model = model
     self.test_data = test_data
     y_pred = model.predict(test_data)
     if len(y_true.shape) > 1:
         self.y_true = np.argmax(y_true, axis=1)
         self.y_pred = np.argmax(y_pred, axis=1)
     else:
         self.y_true = y_true
         self.y_pred = y_pred
     self.classes = classes
     self.name = name
     self.path_to_save = path_to_save
     self.cmap = color_sequence("YlOrRd")
     self.cmap.set_over(color="w")
     self.cmap.set_under(color="#2a7d4f")
     self._edgecolors = []
     self.fontsize = None
 def test_color_sequence_unrecocognized(self):
     """
     Test value errors for unrecognized sequences
     """
     with self.assertRaises(YellowbrickValueError):
         color_sequence('PepperBucks', 3)
示例#14
0
 def test_color_sequence_unrecocognized(self):
     """
     Test value errors for unrecognized sequences
     """
     with self.assertRaises(YellowbrickValueError):
         cmap = color_sequence('PepperBucks', 3)
 def test_color_sequence_unrecocognized(self):
     """
     Test value errors for unrecognized sequences
     """
     with pytest.raises(YellowbrickValueError):
         color_sequence("PepperBucks", 3)