Skip to content

Commit

Permalink
Feature/tabular warning (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
ascillitoe committed Nov 8, 2022
1 parent d3eba1f commit cc31179
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion alibi_detect/cd/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Callable, Dict, List, Optional, Tuple, Union
from alibi_detect.cd.base import BaseUnivariateDrift
from alibi_detect.utils.warnings import deprecated_alias
import warnings


class TabularDrift(BaseUnivariateDrift):
Expand Down Expand Up @@ -88,7 +89,7 @@ def __init__(
self._set_config(locals())

self.alternative = alternative
self.x_ref_categories, self.cat_vars = {}, [] # no categorical features assumed present
# Parse categories_per_feature dict
if isinstance(categories_per_feature, dict):
vals = list(categories_per_feature.values())
int_types = (int, np.int16, np.int32, np.int64)
Expand All @@ -106,6 +107,11 @@ def __init__(
'Dict[int, NoneType], Dict[int, int], Dict[int, List[int]]')
self.x_ref_categories = categories_per_feature
self.cat_vars = list(self.x_ref_categories.keys())
# No categories_per_feature dict so assume no categorical features present
else:
self.x_ref_categories, self.cat_vars = {}, []
warnings.warn('No `categories_per_feature` dict provided so all features are assumed to be numerical. '
'`KSDrift` will be applied to all features.')

def feature_score(self, x_ref: np.ndarray, x: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
"""
Expand Down

0 comments on commit cc31179

Please sign in to comment.