Boris
Boris

Reputation: 2075

Extracting failed columns from Deepchecks

How can I extract from Deepcheck's custom suite result the failed checks + exact "problematic" columns. In my example I had 2 failed checks 'Feature Drift' & 'Multivariate Drift'. For both checks the "problematic" columns were 'col_1' , 'col_5' and 'col_30'.

How using Python I can get something like this :

  1. Check 'Feature Drift' was failed because of : 'col_1' (Drift score = 0.9) , 'col_5'(Drift score = 0.7)
  2. Check 'Multivariate Drift' was failed because of : 'col_1' and 'col_30' with domain_classifier_drift_score = 0.85

My code is :

columns_metadata = {'cat_features' : categorical_cols, 'label':y_label_col } 
train_dataset = Dataset(df = train_df   , **columns_metadata)
test_dataset  = Dataset(df = test_df    , **columns_metadata )

custom_drift_suite = Suite('My_custom_drift_suite',
                         FeatureDrift().add_condition_drift_score_less_than( max_allowed_categorical_score=0.2, max_allowed_numeric_score=0.2),
                        at a time (can’t be recognized with Feature Drift)
                         MultivariateDrift().add_condition_overall_drift_value_less_than(0.4), 
                         LabelDrift(),
                         NewCategoryTrainTest()train set ) 
                            
                        )
custom_suite_ans = custom_drift_suite.run(train_dataset = train_dataset, test_dataset = test_dataset)

Thanks :) Boris

Upvotes: 0

Views: 170

Answers (1)

matanper
matanper

Reputation: 931

The suite result contains check results which contain conditions results. The following code will print the conditions results:

import deepchecks 

for check_result in custom_suite_ans.get_not_passed_checks():
    for condition in check_result.conditions_results:
        print(condition.name + ': ' + condition.details)
        # Access the result of the check - can get columns, etc
        print(check_result.value)

Upvotes: 0

Related Questions