Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves evidentlyai/evidently#1023 #1370

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/evidently/calculations/data_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class FeatureQualityStats:
most_common_not_null_value_percentage: Optional[float] = None
new_in_current_values_count: Optional[int] = None
unused_in_current_values_count: Optional[int] = None
skew: Optional[float] = None

def is_datetime(self):
"""Checks that the object store stats for a datetime feature"""
Expand Down Expand Up @@ -205,6 +206,7 @@ def get_percentage_from_all_values(value: Union[int, float]) -> float:
result.percentile_25 = np.round(common_stats["25%"], 2) # type: ignore[assignment]
result.percentile_50 = np.round(common_stats["50%"], 2) # type: ignore[assignment]
result.percentile_75 = np.round(common_stats["75%"], 2) # type: ignore[assignment]
result.skew = feature.skew()

if feature_type == ColumnType.Datetime:
# cast datetime value to str for datetime features
Expand Down
3 changes: 3 additions & 0 deletions src/evidently/metrics/data_integrity/column_summary_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class Config:
infinite_percentage: Optional[float]
most_common: Optional[Union[int, float]]
most_common_percentage: Optional[float]
skew: Optional[float]


class CategoricalCharacteristics(ColumnCharacteristics):
Expand Down Expand Up @@ -501,6 +502,7 @@ def map_data(stats: FeatureQualityStats) -> ColumnCharacteristics:
infinite_percentage=stats.infinite_percentage,
most_common=stats.most_common_value,
most_common_percentage=stats.most_common_value_percentage,
skew=stats.skew
)
if stats.feature_type == "cat":
return CategoricalCharacteristics(
Expand Down Expand Up @@ -820,6 +822,7 @@ def _metrics_fot_table(self, column_type: str, data_quality_results: ColumnSumma
("50%", "p50", None),
("75%", "p75", None),
("max", "max", None),
("skew", "skew", None),
("unique", "unique", "unique_percentage"),
("most common", "most_common", "most_common_percentage"),
("missing", "missing", "missing_percentage"),
Expand Down
2 changes: 2 additions & 0 deletions tests/metrics/data_interity/test_column_summary_metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
"p25": 1.5,
"p50": 2.0,
"p75": 2.5,
"skew": 0.0,
"std": 1.0,
"unique": 3,
"unique_percentage": 100.0,
Expand All @@ -110,6 +111,7 @@
"p25": 1.5,
"p50": 2.0,
"p75": 2.5,
"skew": 0.0,
"std": 1.0,
"unique": 3,
"unique_percentage": 100.0,
Expand Down
1 change: 1 addition & 0 deletions tests/multitest/metrics/data_integrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def column_summary_metric_period():
p25=1.5,
p50=2,
p75=2.5,
skew=0.0,
std=1,
unique=3,
unique_percentage=100,
Expand Down
Loading