urns:

Deepchecks test suite execution result

"""# validation pre-processing (e.g. dataset preparation) can take place here

data_validator = DeepchecksDataValidator.get_active_data_validator()

suite = data_validator.data_validation(

dataset=dataset,

check_list=[

DeepchecksDataIntegrityCheck.TABULAR_OUTLIER_SAMPLE_DETECTION,

DeepchecksDataIntegrityCheck.TABULAR_STRING_LENGTH_OUT_OF_BOUNDS,

],

# validation post-processing (e.g. interpret results, take actions) can happen here

return suite

The arguments that the Deepchecks Data Validator methods can take in are the same as those used for the Deepchecks standard steps.

Have a look at the complete list of methods and parameters available in the DeepchecksDataValidator API in the SDK docs.

Call Deepchecks directly

You can use the Deepchecks library directly in your custom pipeline steps, and only leverage ZenML's capability of serializing, versioning and storing the SuiteResult objects in its Artifact Store, e.g.:

import pandas as pd

import deepchecks.tabular.checks as tabular_checks

from deepchecks.core.suite import SuiteResult

from deepchecks.tabular import Suite

from deepchecks.tabular import Dataset

from zenml import step

@step

def data_integrity_check(

dataset: pd.DataFrame,

) -> SuiteResult:

"""Custom data integrity check step with Deepchecks

Args:

dataset: a Pandas DataFrame

Returns:

Deepchecks test suite execution result

"""

# validation pre-processing (e.g. dataset preparation) can take place here

train_dataset = Dataset(

dataset,

label='class',

cat_features=['country', 'state']

suite = Suite(name="custom")

check = tabular_checks.OutlierSampleDetection(

nearest_neighbors_percent=0.01,

extent_parameter=3,

check.add_condition_outlier_ratio_less_or_equal(

max_outliers_ratio=0.007,

outlier_score_threshold=0.5,

suite.add(check)

check = tabular_checks.StringLengthOutOfBounds(

num_percentiles=1000,

min_unique_values=3,

check.add_condition_number_of_outliers_less_or_equal(

max_outliers=3,