How to use the yellowbrick.exceptions.YellowbrickError function in yellowbrick

To help you get started, we’ve selected a few yellowbrick examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DistrictDataLabs / yellowbrick / tests / test_classifier / test_threshold.py View on Github external
"""
        message = "requires a probabilistic binary classifier"

        class RoboClassifier(ClassifierMixin):
            """
            Dummy Non-Probabilistic Classifier
            """

            def fit(self, X, y):
                self.classes_ = [0, 1]
                return self

        assert is_classifier(RoboClassifier)
        assert not is_probabilistic(RoboClassifier)

        with pytest.raises(yb.exceptions.YellowbrickError, match=message):
            DiscriminationThreshold(RoboClassifier())
github DistrictDataLabs / yellowbrick / tests / test_classifier / test_learning_curve.py View on Github external
def test_learning_curve_bad_trainsize(self):
        """
        Test learning curve with bad input for training size.
        """

        with self.assertRaises(YellowbrickError):
            visualizer = LearningCurveVisualizer(LinearSVC(),
                train_sizes=10000,
                cv=ShuffleSplit(n_splits=100, test_size=0.2, random_state=0))
            visualizer.fit(X, y)
            visualizer.poof()
github DistrictDataLabs / yellowbrick / tests / test_classifier / test_threshold.py View on Github external
def test_requires_classifier(self):
        """
        Assert requires a classifier
        """
        message = "requires a probabilistic binary classifier"
        assert not is_classifier(Ridge)

        with pytest.raises(yb.exceptions.YellowbrickError, match=message):
            DiscriminationThreshold(Ridge())
github DistrictDataLabs / yellowbrick / tests / test_features / test_pca.py View on Github external
def test_scale_true_4d_exception(self):
        """
        Test PCA visualizer 4 dimensions scaled (catch YellowbrickError).
        """
        params = {"scale": True, "projection": 4}
        msg = "Projection dimensions must be either 2 or 3"
        with pytest.raises(YellowbrickError, match=msg):
            PCA(**params)
github DistrictDataLabs / yellowbrick / tests / test_classifier / test_confusion_matrix.py View on Github external
def test_isclassifier(self):
        """
        Assert that only classifiers can be used with the visualizer.
        """
        model = PassiveAggressiveRegressor()
        message = (
            "This estimator is not a classifier; "
            "try a regression or clustering score visualizer instead!"
        )

        with pytest.raises(yb.exceptions.YellowbrickError, match=message):
            ConfusionMatrix(model)
github DistrictDataLabs / yellowbrick / yellowbrick / exceptions.py View on Github external
method = method or "this method"
        message = (
            "this {} instance is not fitted yet, please call fit "
            "with the appropriate arguments before using {}"
        ).format(estimator.__class__.__name__, method)
        return klass(message)


class DatasetsError(YellowbrickError):
    """
    A problem occured when interacting with data sets.
    """
    pass


class YellowbrickTypeError(YellowbrickError, TypeError):
    """
    There was an unexpected type or none for a property or input.
    """
    pass


class YellowbrickValueError(YellowbrickError, ValueError):
    """
    A bad value was passed into a function.
    """
    pass


class YellowbrickKeyError(YellowbrickError, KeyError):
    """
    An invalid key was used in a hash (dict or set).
github DistrictDataLabs / yellowbrick / yellowbrick / exceptions.py View on Github external
"""
    pass


class YellowbrickKeyError(YellowbrickError, KeyError):
    """
    An invalid key was used in a hash (dict or set).
    """
    pass


##########################################################################
## Assertions
##########################################################################

class YellowbrickAssertionError(YellowbrickError, AssertionError):
    """
    Used to indicate test failures.
    """
    pass


class ImageComparisonFailure(YellowbrickAssertionError):
    """
    Provides a cleaner error when image comparison assertions fail.
    """
    pass


##########################################################################
## Warnings
##########################################################################
github DistrictDataLabs / yellowbrick / yellowbrick / exceptions.py View on Github external
class YellowbrickError(Exception):
    """
    The root exception for all yellowbrick related errors.
    """
    pass


class VisualError(YellowbrickError):
    """
    A problem when interacting with matplotlib or the display framework.
    """
    pass


class ModelError(YellowbrickError):
    """
    A problem when interacting with sklearn or the ML framework.
    """
    pass


class NotFitted(ModelError):
    """
    An action was called that requires a fitted model.
    """

    @classmethod
    def from_estimator(klass, estimator, method=None):
        method = method or "this method"
        message = (
            "this {} instance is not fitted yet, please call fit "
github DistrictDataLabs / yellowbrick / yellowbrick / exceptions.py View on Github external
Exceptions and warnings hierarchy for the yellowbrick library
"""

##########################################################################
## Exceptions Hierarchy
##########################################################################


class YellowbrickError(Exception):
    """
    The root exception for all yellowbrick related errors.
    """
    pass


class VisualError(YellowbrickError):
    """
    A problem when interacting with matplotlib or the display framework.
    """
    pass


class ModelError(YellowbrickError):
    """
    A problem when interacting with sklearn or the ML framework.
    """
    pass


class NotFitted(ModelError):
    """
    An action was called that requires a fitted model.
github DistrictDataLabs / yellowbrick / yellowbrick / classifier / learning_curve.py View on Github external
def __init__(self, model, train_sizes=None, cv=None, n_jobs=1, **kwargs):

        # Call super to initialize the class
        super(LearningCurveVisualizer, self).__init__(model, **kwargs)

        # Set parameters
        self.cv = cv
        self.n_jobs = n_jobs
        self.train_sizes = np.linspace(.1, 1.0, 5) if train_sizes is None else train_sizes

        if not (isinstance(self.train_sizes, np.ndarray)):
            raise YellowbrickError('train_sizes must be np.ndarray or pd.Series')

        # to be set later
        self.train_scores = None
        self.test_scores = None
        self.train_scores_mean = None
        self.train_scores_std = None
        self.test_scores_mean = None
        self.test_scores_std = None