Skip to content

Commit

Permalink
Deprecating the DominantFrequencyChange check (#1685)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItayGabbay committed Jun 27, 2022
1 parent d1ac880 commit 236b16b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# ----------------------------------------------------------------------------
#
"""module contains Dominant Frequency Change check."""
import warnings
from typing import Dict, Optional

import numpy as np
Expand All @@ -28,6 +29,9 @@
class DominantFrequencyChange(TrainTestCheck):
"""Check if dominant values have increased significantly between test and reference data.
.. deprecated:: 0.8.1
The DominantFrequencyChange check is deprecated and will be removed in the 0.11 version.
Parameters
----------
dominance_ratio : float , default: 2
Expand All @@ -50,6 +54,9 @@ def __init__(
self.ratio_change_thres = ratio_change_thres
self.n_top_columns = n_top_columns

warnings.warn('The DominantFrequencyChange check is deprecated and will be removed in the 0.11 version.',
DeprecationWarning)

def run_logic(self, context: Context) -> CheckResult:
"""Run check.
Expand Down
7 changes: 7 additions & 0 deletions deepchecks/tabular/deprecation_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,10 @@
category=DeprecationWarning,
module=r'deepchecks.*'
)

warnings.filterwarnings(
action='once',
message=r'The DominantFrequencyChange check is deprecated.*',
category=DeprecationWarning,
module=r'deepchecks.*'
)
8 changes: 7 additions & 1 deletion tests/base/test_tabular_deprecation_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import pytest

from deepchecks.tabular.checks import (TrainTestFeatureDrift, TrainTestLabelDrift, TrainTestPredictionDrift,
WholeDatasetDrift)
WholeDatasetDrift, DominantFrequencyChange)


def test_deprecation_warning_label_drift():
Expand Down Expand Up @@ -60,3 +60,9 @@ def test_deprecation_warning_whole_dataset_drift():
with warnings.catch_warnings():
warnings.simplefilter('error')
_ = WholeDatasetDrift()


def test_deprecation_dominant_freq_change_warning():
# Test that warning is raised when max_num_categories has value:
with pytest.warns(DeprecationWarning, match='The DominantFrequencyChange check is deprecated'):
_ = DominantFrequencyChange()

0 comments on commit 236b16b

Please sign in to comment.