-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Energy distance num drift test (#400)
* Added energy distance num drift test * removed nans from test example * isort changes
- Loading branch information
1 parent
947b88f
commit f6811df
Showing
4 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from typing import Tuple | ||
|
||
import pandas as pd | ||
from scipy.stats import energy_distance | ||
|
||
from evidently.calculations.stattests.registry import StatTest | ||
from evidently.calculations.stattests.registry import register_stattest | ||
|
||
|
||
def _energy_dist( | ||
reference_data: pd.Series, current_data: pd.Series, feature_type: str, threshold: float | ||
) -> Tuple[float, bool]: | ||
"""Run the energy_distance test of two samples. | ||
Args: | ||
reference_data: reference data | ||
current_data: current data | ||
threshold: all values above this threshold propose a data drift | ||
Returns: | ||
distance: energy distance | ||
test_result: whether the drift is detected | ||
""" | ||
distance = energy_distance(reference_data, current_data) | ||
return distance, distance > threshold | ||
|
||
|
||
energy_dist_test = StatTest( | ||
name="ed", display_name="Energy-distance", func=_energy_dist, allowed_feature_types=["num"], default_threshold=0.1 | ||
) | ||
|
||
register_stattest(energy_dist_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters