datapruning 1.0.9__tar.gz → 1.0.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {datapruning-1.0.9/datapruning.egg-info → datapruning-1.0.10}/PKG-INFO +1 -1
- datapruning-1.0.10/datapruning/engine/explainability.py +64 -0
- {datapruning-1.0.9 → datapruning-1.0.10/datapruning.egg-info}/PKG-INFO +1 -1
- {datapruning-1.0.9 → datapruning-1.0.10}/pyproject.toml +1 -1
- datapruning-1.0.9/datapruning/engine/explainability.py +0 -26
- {datapruning-1.0.9 → datapruning-1.0.10}/LICENSE +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/MANIFEST.in +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/README.md +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/build_src/_core.c +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/__init__.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/algorithms/__init__.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/algorithms/base.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/algorithms/cluster_centroids.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/algorithms/density_pruner.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/algorithms/duplicate_aware.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/algorithms/instance_hardness.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/algorithms/random_undersampler.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/algorithms/registry.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/engine/__init__.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/engine/benchmark.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/engine/intelligence.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/engine/optimizer.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/engine/scanner.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/engine/strategy_display.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/engine/strategy_selector.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/pipeline.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/reports/__init__.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/reports/exporter.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning/sdk.py +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning.egg-info/SOURCES.txt +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning.egg-info/dependency_links.txt +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning.egg-info/requires.txt +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/datapruning.egg-info/top_level.txt +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/setup.cfg +0 -0
- {datapruning-1.0.9 → datapruning-1.0.10}/setup.py +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import pandas as pd
|
|
3
|
+
from datapruning.algorithms.base import BaseOptimizer, OptimizationResult, Explanation
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def _clamp(v: float, lo: float = 0.0, hi: float = 100.0) -> float:
|
|
7
|
+
return max(lo, min(hi, v))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def build_report(optimizer: BaseOptimizer, result: OptimizationResult,
|
|
11
|
+
df_before: pd.DataFrame) -> dict:
|
|
12
|
+
explanation: Explanation = optimizer.explain(result)
|
|
13
|
+
|
|
14
|
+
missing_pct_before = (df_before.isna().sum().sum() / df_before.size) * 100 if df_before.size else 0
|
|
15
|
+
dup_pct_before = (df_before.duplicated().sum() / len(df_before)) * 100 if len(df_before) else 0
|
|
16
|
+
missing_pct_after = (result.optimized_df.isna().sum().sum() / result.optimized_df.size) * 100 \
|
|
17
|
+
if result.optimized_df.size else 0
|
|
18
|
+
dup_pct_after = (result.optimized_df.duplicated().sum() / len(result.optimized_df)) * 100 \
|
|
19
|
+
if len(result.optimized_df) else 0
|
|
20
|
+
|
|
21
|
+
n_cols = len(df_before.columns)
|
|
22
|
+
constant_ratio = 0
|
|
23
|
+
near_constant_ratio = 0
|
|
24
|
+
outlier_ratio = 0
|
|
25
|
+
imbalance_penalty = 0
|
|
26
|
+
correlation_penalty = 0
|
|
27
|
+
|
|
28
|
+
if n_cols > 1 and hasattr(df_before, "describe"):
|
|
29
|
+
const_count = sum(1 for c in df_before.columns if df_before[c].nunique(dropna=False) <= 1)
|
|
30
|
+
constant_ratio = const_count / n_cols
|
|
31
|
+
|
|
32
|
+
for col in df_before.select_dtypes(include="number"):
|
|
33
|
+
q1, q3 = df_before[col].quantile(0.25), df_before[col].quantile(0.75)
|
|
34
|
+
iqr = q3 - q1
|
|
35
|
+
if iqr > 0:
|
|
36
|
+
outliers = ((df_before[col] < q1 - 1.5 * iqr) | (df_before[col] > q3 + 1.5 * iqr)).sum()
|
|
37
|
+
outlier_ratio = max(outlier_ratio, outliers / len(df_before))
|
|
38
|
+
|
|
39
|
+
imbalance_penalty = dup_pct_before / 100
|
|
40
|
+
|
|
41
|
+
quality = _clamp(100 - missing_pct_before * 2 - dup_pct_before * 2 - constant_ratio * 30)
|
|
42
|
+
completeness = _clamp(100 - missing_pct_before * 3)
|
|
43
|
+
balance = _clamp(100 - imbalance_penalty * 50)
|
|
44
|
+
redundancy = _clamp(100 - dup_pct_before * 3)
|
|
45
|
+
complexity = _clamp(100 - outlier_ratio * 40 - constant_ratio * 20)
|
|
46
|
+
|
|
47
|
+
size_reduction = float(1 - (result.rows_after / result.rows_before)) if result.rows_before else 0.0
|
|
48
|
+
training_readiness = _clamp(completeness * 0.4 + balance * 0.3 + redundancy * 0.3)
|
|
49
|
+
optimization_potential = _clamp(size_reduction * 100 + imbalance_penalty * 30 + dup_pct_before * 0.5)
|
|
50
|
+
overall_health = round((quality + completeness + balance + redundancy + complexity) / 5, 1)
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
"explanation": explanation.__dict__,
|
|
54
|
+
"dataset_score": {
|
|
55
|
+
"overall_health": overall_health,
|
|
56
|
+
"quality": round(quality, 1),
|
|
57
|
+
"completeness": round(completeness, 1),
|
|
58
|
+
"balance": round(balance, 1),
|
|
59
|
+
"redundancy": round(redundancy, 1),
|
|
60
|
+
"training_readiness": round(training_readiness, 1),
|
|
61
|
+
"optimization_potential": round(optimization_potential, 1),
|
|
62
|
+
},
|
|
63
|
+
"runtime_seconds": round(result.runtime_seconds, 3),
|
|
64
|
+
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
import pandas as pd
|
|
3
|
-
from datapruning.algorithms.base import BaseOptimizer, OptimizationResult, Explanation
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def build_report(optimizer: BaseOptimizer, result: OptimizationResult,
|
|
7
|
-
df_before: pd.DataFrame) -> dict:
|
|
8
|
-
explanation: Explanation = optimizer.explain(result)
|
|
9
|
-
missing_pct_after = (result.optimized_df.isna().sum().sum() / result.optimized_df.size) * 100 \
|
|
10
|
-
if result.optimized_df.size else 0
|
|
11
|
-
dup_pct_after = (result.optimized_df.duplicated().sum() / len(result.optimized_df)) * 100 \
|
|
12
|
-
if len(result.optimized_df) else 0
|
|
13
|
-
quality = float(max(0, 100 - missing_pct_after * 2 - dup_pct_after * 2))
|
|
14
|
-
size_reduction = float(1 - (result.rows_after / result.rows_before)) if result.rows_before else 0.0
|
|
15
|
-
training_readiness = float(min(100, 70 + size_reduction * 60))
|
|
16
|
-
overall_health = round((quality + training_readiness) / 2, 1)
|
|
17
|
-
return {
|
|
18
|
-
"explanation": explanation.__dict__,
|
|
19
|
-
"dataset_score": {
|
|
20
|
-
"overall_health": overall_health,
|
|
21
|
-
"quality": round(quality, 1),
|
|
22
|
-
"training_readiness": round(training_readiness, 1),
|
|
23
|
-
"optimization_potential": round(size_reduction * 100, 1),
|
|
24
|
-
},
|
|
25
|
-
"runtime_seconds": round(result.runtime_seconds, 3),
|
|
26
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|