-
-
Notifications
You must be signed in to change notification settings - Fork 562
/
Copy pathexceptions.py
139 lines (94 loc) · 2.9 KB
/
exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# yellowbrick.exceptions
# Exceptions hierarchy for the yellowbrick library
#
# Author: Benjamin Bengfort
# Created: Fri Jun 03 10:39:41 2016 -0700
#
# Copyright (C) 2016 The sckit-yb developers
# For license information, see LICENSE.txt
#
# ID: exceptions.py [cb75e0e] [email protected] $
"""
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.
"""
@classmethod
def from_estimator(klass, estimator, method=None):
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).
"""
pass
class YellowbrickAttributeError(YellowbrickError, AttributeError):
"""
A required attribute is missing on the estimator.
"""
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
##########################################################################
class YellowbrickWarning(UserWarning):
"""
Warning class used to notify users of Yellowbrick-specific issues.
"""
pass
class DataWarning(YellowbrickWarning):
"""
The supplied data has an issue that may produce unexpected visualizations.
"""
pass