Implementation:DistrictDataLabs Yellowbrick Exceptions
| Knowledge Sources | |
|---|---|
| Domains | Error_Handling, Utilities |
| Last Updated | 2026-02-08 05:00 GMT |
Overview
Custom exception and warning hierarchy for the Yellowbrick library, providing fine-grained error categorization for visualization, model, dataset, and type errors.
Description
The exceptions module defines the complete error hierarchy for Yellowbrick. YellowbrickError is the root exception, with subclasses for visual errors (matplotlib issues), model errors (sklearn issues), dataset errors, and standard Python error types (TypeError, ValueError, KeyError, AttributeError) prefixed with Yellowbrick for catch specificity. NotFitted includes a classmethod factory for estimator-specific messages. Warning classes YellowbrickWarning and DataWarning signal non-fatal issues.
Usage
Import specific exception classes when writing error handling around Yellowbrick operations, or when subclassing Yellowbrick classes and needing to raise appropriate errors.
Code Reference
Source Location
- Repository: DistrictDataLabs_Yellowbrick
- File: yellowbrick/exceptions.py
- Lines: 1-139
Signature
class YellowbrickError(Exception): ...
class VisualError(YellowbrickError): ...
class ModelError(YellowbrickError): ...
class NotFitted(ModelError):
@classmethod
def from_estimator(klass, estimator, method=None): ...
class DatasetsError(YellowbrickError): ...
class YellowbrickTypeError(YellowbrickError, TypeError): ...
class YellowbrickValueError(YellowbrickError, ValueError): ...
class YellowbrickKeyError(YellowbrickError, KeyError): ...
class YellowbrickAttributeError(YellowbrickError, AttributeError): ...
class YellowbrickWarning(UserWarning): ...
class DataWarning(YellowbrickWarning): ...
Import
from yellowbrick.exceptions import (
YellowbrickError, NotFitted, YellowbrickValueError, YellowbrickTypeError,
DatasetsError, YellowbrickWarning, DataWarning,
)
I/O Contract
Exception Hierarchy
| Exception | Parent | Purpose |
|---|---|---|
| YellowbrickError | Exception | Root for all Yellowbrick errors |
| VisualError | YellowbrickError | Matplotlib/display issues |
| ModelError | YellowbrickError | Sklearn/ML framework issues |
| NotFitted | ModelError | Estimator not yet fitted |
| DatasetsError | YellowbrickError | Dataset loading/download issues |
| YellowbrickTypeError | YellowbrickError, TypeError | Unexpected type |
| YellowbrickValueError | YellowbrickError, ValueError | Bad value |
| YellowbrickKeyError | YellowbrickError, KeyError | Invalid key |
| YellowbrickAttributeError | YellowbrickError, AttributeError | Missing attribute |
| YellowbrickWarning | UserWarning | Non-fatal warning |
| DataWarning | YellowbrickWarning | Data quality warning |
Usage Examples
from yellowbrick.exceptions import NotFitted, YellowbrickValueError
# Check if estimator is fitted
try:
viz.show()
except NotFitted as e:
print(f"Must call fit() first: {e}")
# Handle bad input
try:
viz.fit(X, y)
except YellowbrickValueError as e:
print(f"Invalid input: {e}")