Evidently
zenml.integrations.evidently
Initialization of the Evidently integration.
The Evidently integration provides a way to monitor your models in production. It includes a way to detect data drift and different kinds of model performance issues.
The results of Evidently calculations can either be exported as an interactive dashboard (visualized as an html file or in your Jupyter notebook), or as a JSON file.
Attributes
EVIDENTLY = 'evidently'
module-attribute
EVIDENTLY_DATA_VALIDATOR_FLAVOR = 'evidently'
module-attribute
numba_logger = logging.getLogger('numba')
module-attribute
Classes
EvidentlyIntegration
Bases: Integration
Evidently integration for ZenML.
Functions
flavors() -> List[Type[Flavor]]
classmethod
Declare the stack component flavors for the Great Expectations integration.
Returns:
Type | Description |
---|---|
List[Type[Flavor]]
|
List of stack component flavors for this integration. |
Source code in src/zenml/integrations/evidently/__init__.py
80 81 82 83 84 85 86 87 88 89 90 91 |
|
get_requirements(target_os: Optional[str] = None, python_version: Optional[str] = None) -> List[str]
classmethod
Method to get the requirements for the integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_os
|
Optional[str]
|
The target operating system to get the requirements for. |
None
|
python_version
|
Optional[str]
|
The Python version to use for the requirements. |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of requirements. |
Source code in src/zenml/integrations/evidently/__init__.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
Flavor
Class for ZenML Flavors.
Attributes
config_class: Type[StackComponentConfig]
abstractmethod
property
Returns StackComponentConfig
config class.
Returns:
Type | Description |
---|---|
Type[StackComponentConfig]
|
The config class. |
config_schema: Dict[str, Any]
property
The config schema for a flavor.
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
The config schema. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[StackComponent]
abstractmethod
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[StackComponent]
|
The implementation class for this flavor. |
logo_url: Optional[str]
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
Optional[str]
|
The flavor logo. |
name: str
abstractmethod
property
The flavor name.
Returns:
Type | Description |
---|---|
str
|
The flavor name. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
service_connector_requirements: Optional[ServiceConnectorRequirements]
property
Service connector resource requirements for service connectors.
Specifies resource requirements that are used to filter the available service connector types that are compatible with this flavor.
Returns:
Type | Description |
---|---|
Optional[ServiceConnectorRequirements]
|
Requirements for compatible service connectors, if a service |
Optional[ServiceConnectorRequirements]
|
connector is required for this flavor. |
type: StackComponentType
abstractmethod
property
Functions
from_model(flavor_model: FlavorResponse) -> Flavor
classmethod
Loads a flavor from a model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flavor_model
|
FlavorResponse
|
The model to load from. |
required |
Raises:
Type | Description |
---|---|
CustomFlavorImportError
|
If the custom flavor can't be imported. |
ImportError
|
If the flavor can't be imported. |
Returns:
Type | Description |
---|---|
Flavor
|
The loaded flavor. |
Source code in src/zenml/stack/flavor.py
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
generate_default_docs_url() -> str
Generate the doc urls for all inbuilt and integration flavors.
Note that this method is not going to be useful for custom flavors, which do not have any docs in the main zenml docs.
Returns:
Type | Description |
---|---|
str
|
The complete url to the zenml documentation |
Source code in src/zenml/stack/flavor.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
generate_default_sdk_docs_url() -> str
Generate SDK docs url for a flavor.
Returns:
Type | Description |
---|---|
str
|
The complete url to the zenml SDK docs |
Source code in src/zenml/stack/flavor.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
|
to_model(integration: Optional[str] = None, is_custom: bool = True) -> FlavorRequest
Converts a flavor to a model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
integration
|
Optional[str]
|
The integration to use for the model. |
None
|
is_custom
|
bool
|
Whether the flavor is a custom flavor. |
True
|
Returns:
Type | Description |
---|---|
FlavorRequest
|
The model. |
Source code in src/zenml/stack/flavor.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
Integration
Base class for integration in ZenML.
Functions
activate() -> None
classmethod
Abstract method to activate the integration.
Source code in src/zenml/integrations/integration.py
175 176 177 |
|
check_installation() -> bool
classmethod
Method to check whether the required packages are installed.
Returns:
Type | Description |
---|---|
bool
|
True if all required packages are installed, False otherwise. |
Source code in src/zenml/integrations/integration.py
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 |
|
flavors() -> List[Type[Flavor]]
classmethod
Abstract method to declare new stack component flavors.
Returns:
Type | Description |
---|---|
List[Type[Flavor]]
|
A list of new stack component flavors. |
Source code in src/zenml/integrations/integration.py
179 180 181 182 183 184 185 186 |
|
get_requirements(target_os: Optional[str] = None, python_version: Optional[str] = None) -> List[str]
classmethod
Method to get the requirements for the integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_os
|
Optional[str]
|
The target operating system to get the requirements for. |
None
|
python_version
|
Optional[str]
|
The Python version to use for the requirements. |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of requirements. |
Source code in src/zenml/integrations/integration.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
get_uninstall_requirements(target_os: Optional[str] = None) -> List[str]
classmethod
Method to get the uninstall requirements for the integration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_os
|
Optional[str]
|
The target operating system to get the requirements for. |
None
|
Returns:
Type | Description |
---|---|
List[str]
|
A list of requirements. |
Source code in src/zenml/integrations/integration.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
plugin_flavors() -> List[Type[BasePluginFlavor]]
classmethod
Abstract method to declare new plugin flavors.
Returns:
Type | Description |
---|---|
List[Type[BasePluginFlavor]]
|
A list of new plugin flavors. |
Source code in src/zenml/integrations/integration.py
188 189 190 191 192 193 194 195 |
|
Modules
column_mapping
ZenML representation of an Evidently column mapping.
Classes
EvidentlyColumnMapping
Bases: BaseModel
Column mapping configuration for Evidently.
This class is a 1-to-1 serializable analogue of Evidently's ColumnMapping data type that can be used as a step configuration field (see https://docs.evidentlyai.com/user-guide/input-data/column-mapping).
Attributes:
Name | Type | Description |
---|---|---|
target |
Optional[str]
|
target column |
prediction |
Optional[Union[str, Sequence[str]]]
|
target column |
datetime |
Optional[str]
|
datetime column |
id |
Optional[str]
|
id column |
numerical_features |
Optional[List[str]]
|
numerical features |
categorical_features |
Optional[List[str]]
|
categorical features |
datetime_features |
Optional[List[str]]
|
datetime features |
target_names |
Optional[List[str]]
|
target column names |
task |
Optional[str]
|
model task |
pos_label |
Optional[Union[str, int]]
|
positive label |
text_features |
Optional[List[str]]
|
text features |
to_evidently_column_mapping() -> ColumnMapping
Convert this Pydantic object to an Evidently ColumnMapping object.
Returns:
Type | Description |
---|---|
ColumnMapping
|
An Evidently column mapping converted from this Pydantic object. |
Source code in src/zenml/integrations/evidently/column_mapping.py
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 |
|
data_validators
Initialization of the Evidently data validator for ZenML.
Classes
EvidentlyDataValidator(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: BaseDataValidator
Evidently data validator stack component.
Source code in src/zenml/stack/stack_component.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
data_profiling(dataset: pd.DataFrame, comparison_dataset: Optional[pd.DataFrame] = None, profile_list: Optional[Sequence[EvidentlyMetricConfig]] = None, column_mapping: Optional[ColumnMapping] = None, report_options: Sequence[Tuple[str, Dict[str, Any]]] = [], download_nltk_data: bool = False, **kwargs: Any) -> Report
Analyze a dataset and generate a data report with Evidently.
The method takes in an optional list of Evidently options to be passed
to the report constructor (report_options
). Each element in the list must be
composed of two items: the first is a full class path of an Evidently
option dataclass
, the second is a dictionary of kwargs with the actual
option parameters, e.g.:
options = [
(
"evidently.options.ColorOptions",{
"primary_color": "#5a86ad",
"fill_color": "#fff4f2",
"zero_line_color": "#016795",
"current_data_color": "#c292a1",
"reference_data_color": "#017b92",
}
),
]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
DataFrame
|
Target dataset to be profiled. When a comparison dataset is provided, this dataset is considered the reference dataset. |
required |
comparison_dataset
|
Optional[DataFrame]
|
Optional dataset to be used for data profiles that require a current dataset for comparison (e.g data drift profiles). |
None
|
profile_list
|
Optional[Sequence[EvidentlyMetricConfig]]
|
List of Evidently metric configurations to be included in the report. If not provided, all available metric presets will be included. |
None
|
column_mapping
|
Optional[ColumnMapping]
|
Properties of the DataFrame columns used |
None
|
report_options
|
Sequence[Tuple[str, Dict[str, Any]]]
|
List of Evidently options to be passed to the report constructor. |
[]
|
download_nltk_data
|
bool
|
Whether to download NLTK data for text metrics. Defaults to False. |
False
|
**kwargs
|
Any
|
Extra keyword arguments (unused). |
{}
|
Returns:
Type | Description |
---|---|
Report
|
The Evidently Report as JSON object and as HTML. |
Source code in src/zenml/integrations/evidently/data_validators/evidently_data_validator.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
data_validation(dataset: Any, comparison_dataset: Optional[Any] = None, check_list: Optional[Sequence[EvidentlyTestConfig]] = None, test_options: Sequence[Tuple[str, Dict[str, Any]]] = [], column_mapping: Optional[ColumnMapping] = None, download_nltk_data: bool = False, **kwargs: Any) -> TestSuite
Validate a dataset with Evidently.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Any
|
Target dataset to be validated. |
required |
comparison_dataset
|
Optional[Any]
|
Optional dataset to be used for data validation that require a baseline for comparison (e.g data drift validation). |
None
|
check_list
|
Optional[Sequence[EvidentlyTestConfig]]
|
List of Evidently test configurations to be included in the test suite. If not provided, all available test presets will be included. |
None
|
test_options
|
Sequence[Tuple[str, Dict[str, Any]]]
|
List of Evidently options to be passed to the test suite constructor. |
[]
|
column_mapping
|
Optional[ColumnMapping]
|
Properties of the DataFrame columns used |
None
|
download_nltk_data
|
bool
|
Whether to download NLTK data for text tests. Defaults to False. |
False
|
**kwargs
|
Any
|
Extra keyword arguments (unused). |
{}
|
Returns:
Type | Description |
---|---|
TestSuite
|
The Evidently Test Suite as JSON object and as HTML. |
Source code in src/zenml/integrations/evidently/data_validators/evidently_data_validator.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
Modules
evidently_data_validator
Implementation of the Evidently data validator.
EvidentlyDataValidator(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: BaseDataValidator
Evidently data validator stack component.
Source code in src/zenml/stack/stack_component.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
|
data_profiling(dataset: pd.DataFrame, comparison_dataset: Optional[pd.DataFrame] = None, profile_list: Optional[Sequence[EvidentlyMetricConfig]] = None, column_mapping: Optional[ColumnMapping] = None, report_options: Sequence[Tuple[str, Dict[str, Any]]] = [], download_nltk_data: bool = False, **kwargs: Any) -> Report
Analyze a dataset and generate a data report with Evidently.
The method takes in an optional list of Evidently options to be passed
to the report constructor (report_options
). Each element in the list must be
composed of two items: the first is a full class path of an Evidently
option dataclass
, the second is a dictionary of kwargs with the actual
option parameters, e.g.:
options = [
(
"evidently.options.ColorOptions",{
"primary_color": "#5a86ad",
"fill_color": "#fff4f2",
"zero_line_color": "#016795",
"current_data_color": "#c292a1",
"reference_data_color": "#017b92",
}
),
]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
DataFrame
|
Target dataset to be profiled. When a comparison dataset is provided, this dataset is considered the reference dataset. |
required |
comparison_dataset
|
Optional[DataFrame]
|
Optional dataset to be used for data profiles that require a current dataset for comparison (e.g data drift profiles). |
None
|
profile_list
|
Optional[Sequence[EvidentlyMetricConfig]]
|
List of Evidently metric configurations to be included in the report. If not provided, all available metric presets will be included. |
None
|
column_mapping
|
Optional[ColumnMapping]
|
Properties of the DataFrame columns used |
None
|
report_options
|
Sequence[Tuple[str, Dict[str, Any]]]
|
List of Evidently options to be passed to the report constructor. |
[]
|
download_nltk_data
|
bool
|
Whether to download NLTK data for text metrics. Defaults to False. |
False
|
**kwargs
|
Any
|
Extra keyword arguments (unused). |
{}
|
Returns:
Type | Description |
---|---|
Report
|
The Evidently Report as JSON object and as HTML. |
Source code in src/zenml/integrations/evidently/data_validators/evidently_data_validator.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
data_validation(dataset: Any, comparison_dataset: Optional[Any] = None, check_list: Optional[Sequence[EvidentlyTestConfig]] = None, test_options: Sequence[Tuple[str, Dict[str, Any]]] = [], column_mapping: Optional[ColumnMapping] = None, download_nltk_data: bool = False, **kwargs: Any) -> TestSuite
Validate a dataset with Evidently.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Any
|
Target dataset to be validated. |
required |
comparison_dataset
|
Optional[Any]
|
Optional dataset to be used for data validation that require a baseline for comparison (e.g data drift validation). |
None
|
check_list
|
Optional[Sequence[EvidentlyTestConfig]]
|
List of Evidently test configurations to be included in the test suite. If not provided, all available test presets will be included. |
None
|
test_options
|
Sequence[Tuple[str, Dict[str, Any]]]
|
List of Evidently options to be passed to the test suite constructor. |
[]
|
column_mapping
|
Optional[ColumnMapping]
|
Properties of the DataFrame columns used |
None
|
download_nltk_data
|
bool
|
Whether to download NLTK data for text tests. Defaults to False. |
False
|
**kwargs
|
Any
|
Extra keyword arguments (unused). |
{}
|
Returns:
Type | Description |
---|---|
TestSuite
|
The Evidently Test Suite as JSON object and as HTML. |
Source code in src/zenml/integrations/evidently/data_validators/evidently_data_validator.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
|
flavors
Evidently integration flavors.
Classes
EvidentlyDataValidatorFlavor
Bases: BaseDataValidatorFlavor
Evidently data validator flavor.
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[EvidentlyDataValidator]
property
Implementation class.
Returns:
Type | Description |
---|---|
Type[EvidentlyDataValidator]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
Type | Description |
---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
Modules
evidently_data_validator_flavor
Evidently data validator flavor.
EvidentlyDataValidatorFlavor
Bases: BaseDataValidatorFlavor
Evidently data validator flavor.
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[EvidentlyDataValidator]
property
Implementation class.
Returns:
Type | Description |
---|---|
Type[EvidentlyDataValidator]
|
The implementation class. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name: str
property
Name of the flavor.
Returns:
Type | Description |
---|---|
str
|
The name of the flavor. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
Type | Description |
---|---|
Optional[str]
|
A flavor SDK docs url. |
metrics
ZenML declarative representation of Evidently Metrics.
Classes
EvidentlyMetricConfig
Bases: BaseModel
Declarative Evidently Metric configuration.
This is a declarative representation of the configuration that goes into an Evidently Metric, MetricPreset or Metric generator instance. We need this to be able to store the configuration as part of a ZenML step parameter and later instantiate the Evidently Metric from it.
This representation covers all 3 possible ways of configuring an Evidently Metric or Metric-like object that can later be used in an Evidently Report:
- A Metric (derived from the Metric class).
- A MetricPreset (derived from the MetricPreset class).
- A column Metric generator (derived from the BaseGenerator class).
Ideally, it should be possible to just pass a Metric or Metric-like object to this class and have it automatically derive the configuration used to instantiate it. Unfortunately, this is not possible because the Evidently Metric classes are not designed in a way that allows us to extract the constructor parameters from them in a generic way.
Attributes:
Name | Type | Description |
---|---|---|
class_path |
str
|
The full class path of the Evidently Metric class. |
parameters |
Dict[str, Any]
|
The parameters of the Evidently Metric. |
is_generator |
bool
|
Whether this is an Evidently column Metric generator. |
columns |
Optional[Union[str, List[str]]]
|
The columns that the Evidently column Metric generator is
applied to. Only used if |
skip_id_column |
bool
|
Whether to skip the ID column when applying the
Evidently Metric generator. Only used if |
default_metrics() -> List[EvidentlyMetricConfig]
classmethod
Default Evidently metric configurations.
Call this to fetch a default list of Evidently metrics to use in cases
where no metrics are explicitly configured for a data validator.
All available Evidently MetricPreset classes are used, except for the
TextOverviewPreset
which requires a text column, which we don't have
by default.
Returns:
Type | Description |
---|---|
List[EvidentlyMetricConfig]
|
A list of EvidentlyMetricConfig objects to use as default metrics. |
Source code in src/zenml/integrations/evidently/metrics.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
|
get_metric_class(metric_name: str) -> Union[Metric, MetricPreset]
staticmethod
Get the Evidently metric or metric preset class from a string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metric_name
|
str
|
The metric or metric preset class or full class path. |
required |
Returns:
Type | Description |
---|---|
Union[Metric, MetricPreset]
|
The Evidently metric or metric preset class. |
Raises:
Type | Description |
---|---|
ValueError
|
If the name cannot be converted into a valid Evidently metric or metric preset class. |
Source code in src/zenml/integrations/evidently/metrics.py
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 |
|
metric(metric: Union[Type[Metric], Type[MetricPreset], str], **parameters: Any) -> EvidentlyMetricConfig
classmethod
Create a declarative configuration for an Evidently Metric.
Call this method to get a declarative representation for the configuration of an Evidently Metric.
Some examples
from zenml.integrations.evidently.data_validators import EvidentlyMetric
# Configure an Evidently MetricPreset using its class name
config = EvidentlyMetric.metric("DataDriftPreset")
from zenml.integrations.evidently.data_validators import EvidentlyMetric
# Configure an Evidently MetricPreset using its full class path
config = EvidentlyMetric.metric(
"evidently.metric_preset.DataDriftPreset"
)
from zenml.integrations.evidently.data_validators import EvidentlyMetric
# Configure an Evidently Metric using its class and pass additional
# parameters
from evidently.metrics import ColumnSummaryMetric
config = EvidentlyMetric.metric(
ColumnSummaryMetric, column_name="age"
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metric
|
Union[Type[Metric], Type[MetricPreset], str]
|
The Evidently Metric or MetricPreset class, class name or class path. |
required |
parameters
|
Any
|
Additional optional parameters needed to instantiate the Evidently Metric or MetricPreset. |
{}
|
Returns:
Type | Description |
---|---|
EvidentlyMetricConfig
|
The EvidentlyMetric declarative representation of the Evidently |
EvidentlyMetricConfig
|
Metric configuration. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
Source code in src/zenml/integrations/evidently/metrics.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
|
metric_generator(metric: Union[Type[Metric], str], columns: Optional[Union[str, List[str]]] = None, skip_id_column: bool = False, **parameters: Any) -> EvidentlyMetricConfig
classmethod
Create a declarative configuration for an Evidently column Metric generator.
Call this method to get a declarative representation for the configuration of an Evidently column Metric generator.
The columns
, skip_id_column
and parameters
arguments will be
passed to the Evidently generate_column_metrics
function:
- if
columns
is a list, it is interpreted as a list of column names. - if
columns
is a string, it can be one of values:- "all" - use all columns, including target/prediction columns
- "num" - for numeric features
- "cat" - for category features
- "text" - for text features
- "features" - for all features, not target/prediction columns.
- a None value is the same as "all".
Some examples
from zenml.integrations.evidently.data_validators import EvidentlyMetric
# Configure an Evidently Metric generator using a Metric class name
# and pass additional parameters
config = EvidentlyMetric.metric_generator(
"ColumnQuantileMetric", columns="num", quantile=0.5
)
from zenml.integrations.evidently.data_validators import EvidentlyMetric
# Configure an Evidently Metric generator using a full Metric class
# path
config = EvidentlyMetric.metric_generator(
"evidently.metrics.ColumnSummaryMetric", columns=["age", "name"]
)
from zenml.integrations.evidently.data_validators import EvidentlyMetric
# Configure an Evidently Metric generator using a Metric class
from evidently.metrics import ColumnDriftMetric
config = EvidentlyMetric.metric_generator(
ColumnDriftMetric, columns="all", skip_id_column=True
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metric
|
Union[Type[Metric], str]
|
The Evidently Metric class, class name or class path to use for the generator. |
required |
columns
|
Optional[Union[str, List[str]]]
|
The columns to apply the generator to. Takes the same
values that the Evidently |
None
|
skip_id_column
|
bool
|
Whether to skip the ID column when applying the generator. |
False
|
parameters
|
Any
|
Additional optional parameters needed to instantiate the
Evidently Metric. These will be passed to the Evidently
|
{}
|
Returns:
Type | Description |
---|---|
EvidentlyMetricConfig
|
The EvidentlyMetric declarative representation of the Evidently |
EvidentlyMetricConfig
|
Metric generator configuration. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
Source code in src/zenml/integrations/evidently/metrics.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
to_evidently_metric() -> Union[Metric, MetricPreset, BaseGenerator]
Create an Evidently Metric, MetricPreset or metric generator object.
Call this method to create an Evidently Metric, MetricPreset or metric generator instance from its declarative representation.
Returns:
Type | Description |
---|---|
Union[Metric, MetricPreset, BaseGenerator]
|
The Evidently Metric, MetricPreset or metric generator object. |
Raises:
Type | Description |
---|---|
ValueError
|
If the Evidently Metric, MetricPreset or column metric generator could not be instantiated. |
Source code in src/zenml/integrations/evidently/metrics.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
|
Functions
Modules
steps
Initialization of the Evidently Standard Steps.
Classes
Functions
Modules
evidently_report
Implementation of the Evidently Report Step.
evidently_report_step(reference_dataset: pd.DataFrame, comparison_dataset: Optional[pd.DataFrame] = None, column_mapping: Optional[EvidentlyColumnMapping] = None, ignored_cols: Optional[List[str]] = None, metrics: Optional[List[EvidentlyMetricConfig]] = None, report_options: Optional[Sequence[Tuple[str, Dict[str, Any]]]] = None, download_nltk_data: bool = False) -> Tuple[Annotated[str, report_json], Annotated[HTMLString, report_html]]
Generate an Evidently report on one or two pandas datasets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reference_dataset
|
DataFrame
|
a Pandas DataFrame |
required |
comparison_dataset
|
Optional[DataFrame]
|
a Pandas DataFrame of new data you wish to compare against the reference data |
None
|
column_mapping
|
Optional[EvidentlyColumnMapping]
|
properties of the DataFrame columns used |
None
|
ignored_cols
|
Optional[List[str]]
|
columns to ignore during the Evidently report step |
None
|
metrics
|
Optional[List[EvidentlyMetricConfig]]
|
a list of Evidently metric configurations to use for the report. |
None
|
report_options
|
Optional[Sequence[Tuple[str, Dict[str, Any]]]]
|
a list of tuples containing the name of the report and a dictionary of options for the report. |
None
|
download_nltk_data
|
bool
|
whether to download the NLTK data for the report step. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Annotated[str, report_json]
|
A tuple containing the Evidently report in JSON and HTML |
Annotated[HTMLString, report_html]
|
formats. |
Source code in src/zenml/integrations/evidently/steps/evidently_report.py
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 |
|
evidently_test
Implementation of the Evidently Test Step.
evidently_test_step(reference_dataset: pd.DataFrame, comparison_dataset: Optional[pd.DataFrame], column_mapping: Optional[EvidentlyColumnMapping] = None, ignored_cols: Optional[List[str]] = None, tests: Optional[List[EvidentlyTestConfig]] = None, test_options: Optional[Sequence[Tuple[str, Dict[str, Any]]]] = None, download_nltk_data: bool = False) -> Tuple[Annotated[str, test_json], Annotated[HTMLString, test_html]]
Run an Evidently test suite on one or two pandas datasets.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reference_dataset
|
DataFrame
|
a Pandas DataFrame |
required |
comparison_dataset
|
Optional[DataFrame]
|
a Pandas DataFrame of new data you wish to compare against the reference data |
required |
column_mapping
|
Optional[EvidentlyColumnMapping]
|
properties of the DataFrame columns used |
None
|
ignored_cols
|
Optional[List[str]]
|
columns to ignore during the Evidently profile step |
None
|
tests
|
Optional[List[EvidentlyTestConfig]]
|
a list of Evidently test configuration to use for the test suite. |
None
|
test_options
|
Optional[Sequence[Tuple[str, Dict[str, Any]]]]
|
a list of tuples containing the name of the test and a dictionary of options for the test. |
None
|
download_nltk_data
|
bool
|
whether to download the NLTK data for the report step. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
Tuple[Annotated[str, test_json], Annotated[HTMLString, test_html]]
|
A tuple containing the TestSuite in JSON and HTML formats. |
Raises:
Type | Description |
---|---|
ValueError
|
If ignored_cols is an empty list |
ValueError
|
If column is not found in reference or comparison dataset |
Source code in src/zenml/integrations/evidently/steps/evidently_test.py
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 |
|
tests
ZenML declarative representation of Evidently Tests.
Classes
EvidentlyTestConfig
Bases: BaseModel
Declarative Evidently Test configuration.
This is a declarative representation of the configuration that goes into an Evidently Test, TestPreset or Test generator instance. We need this to be able to store the configuration as part of a ZenML step parameter and later instantiate the Evidently Test from it.
This representation covers all 3 possible ways of configuring an Evidently Test or Test-like object that can later be used in an Evidently TestSuite:
- A Test (derived from the Test class).
- A TestPreset (derived from the TestPreset class).
- A column Test generator (derived from the BaseGenerator class).
Ideally, it should be possible to just pass a Test or Test-like object to this class and have it automatically derive the configuration used to instantiate it. Unfortunately, this is not possible because the Evidently Test classes are not designed in a way that allows us to extract the constructor parameters from them in a generic way.
Attributes:
Name | Type | Description |
---|---|---|
class_path |
str
|
The full class path of the Evidently Test class. |
parameters |
Dict[str, Any]
|
The parameters of the Evidently Test. |
is_generator |
bool
|
Whether this is an Evidently column Test generator. |
columns |
Optional[Union[str, List[str]]]
|
The columns that the Evidently column Test generator is
applied to. Only used if |
default_tests() -> List[EvidentlyTestConfig]
classmethod
Default Evidently test configurations.
Call this to fetch a default list of Evidently tests to use in cases where no tests are explicitly configured for a data validator. All available Evidently TestPreset classes are used.
Returns:
Type | Description |
---|---|
List[EvidentlyTestConfig]
|
A list of EvidentlyTestConfig objects to use as default tests. |
Source code in src/zenml/integrations/evidently/tests.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
get_test_class(test_name: str) -> Union[Test, TestPreset]
staticmethod
Get the Evidently test or test preset class from a string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test_name
|
str
|
The test or test preset class or full class path. |
required |
Returns:
Type | Description |
---|---|
Union[Test, TestPreset]
|
The Evidently test or test preset class. |
Raises:
Type | Description |
---|---|
ValueError
|
If the name cannot be converted into a valid Evidently test or test preset class. |
Source code in src/zenml/integrations/evidently/tests.py
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 |
|
test(test: Union[Type[Test], Type[TestPreset], str], **parameters: Any) -> EvidentlyTestConfig
classmethod
Create a declarative configuration for an Evidently Test.
Call this method to get a declarative representation for the configuration of an Evidently Test.
Some examples
from zenml.integrations.evidently.data_validators import EvidentlyTest
# Configure an Evidently TestPreset using its class name
config = EvidentlyTest.test("DataDriftPreset")
from zenml.integrations.evidently.data_validators import EvidentlyTest
# Configure an Evidently TestPreset using its full class path
config = EvidentlyTest.test(
"evidently.test_preset.DataDriftPreset"
)
from zenml.integrations.evidently.data_validators import EvidentlyTest
# Configure an Evidently Test using its class and pass additional
# parameters
from evidently.tests import ColumnSummaryTest
config = EvidentlyTest.test(
ColumnSummaryTest, column_name="age"
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test
|
Union[Type[Test], Type[TestPreset], str]
|
The Evidently Test or TestPreset class, class name or class path. |
required |
parameters
|
Any
|
Additional optional parameters needed to instantiate the Evidently Test or TestPreset. |
{}
|
Returns:
Type | Description |
---|---|
EvidentlyTestConfig
|
The EvidentlyTest declarative representation of the Evidently |
EvidentlyTestConfig
|
Test configuration. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
Source code in src/zenml/integrations/evidently/tests.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
test_generator(test: Union[Type[Test], str], columns: Optional[Union[str, List[str]]] = None, **parameters: Any) -> EvidentlyTestConfig
classmethod
Create a declarative configuration for an Evidently column Test generator.
Call this method to get a declarative representation for the configuration of an Evidently column Test generator.
The columns
, parameters
arguments will be
passed to the Evidently generate_column_tests
function:
- if
columns
is a list, it is interpreted as a list of column names. - if
columns
is a string, it can be one of values:- "all" - use all columns, including target/prediction columns
- "num" - for numeric features
- "cat" - for category features
- "text" - for text features
- "features" - for all features, not target/prediction columns.
- a None value is the same as "all".
Some examples
from zenml.integrations.evidently.data_validators import EvidentlyTest
# Configure an Evidently Test generator using a Test class name
# and pass additional parameters
config = EvidentlyTest.test_generator(
"TestColumnValueMin", columns="num", gt=0.5
)
from zenml.integrations.evidently.data_validators import EvidentlyTest
# Configure an Evidently Test generator using a full Test class
# path
config = EvidentlyTest.test_generator(
"evidently.tests.TestColumnShareOfMissingValues", columns=["age", "name"]
)
from zenml.integrations.evidently.data_validators import EvidentlyTest
# Configure an Evidently Test generator using a Test class
from evidently.tests import TestColumnQuantile
config = EvidentlyTest.test_generator(
TestColumnQuantile, columns="all", quantile=0.5
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
test
|
Union[Type[Test], str]
|
The Evidently Test class, class name or class path to use for the generator. |
required |
columns
|
Optional[Union[str, List[str]]]
|
The columns to apply the generator to. Takes the same
values that the Evidently |
None
|
parameters
|
Any
|
Additional optional parameters needed to instantiate the
Evidently Test. These will be passed to the Evidently
|
{}
|
Returns:
Type | Description |
---|---|
EvidentlyTestConfig
|
The EvidentlyTest declarative representation of the Evidently |
EvidentlyTestConfig
|
Test generator configuration. |
Raises:
Type | Description |
---|---|
ValueError
|
If |
Source code in src/zenml/integrations/evidently/tests.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
to_evidently_test() -> Union[Test, TestPreset, BaseGenerator]
Create an Evidently Test, TestPreset or test generator object.
Call this method to create an Evidently Test, TestPreset or test generator instance from its declarative representation.
Returns:
Type | Description |
---|---|
Union[Test, TestPreset, BaseGenerator]
|
The Evidently Test, TestPreset or test generator object. |
Raises:
Type | Description |
---|---|
ValueError
|
If the Evidently Test, TestPreset or column test generator could not be instantiated. |
Source code in src/zenml/integrations/evidently/tests.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
|