datapruning 2.1.2__tar.gz → 2.1.3__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.
Files changed (64) hide show
  1. datapruning-2.1.3/PKG-INFO +148 -0
  2. datapruning-2.1.3/README.md +118 -0
  3. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/__init__.py +2 -0
  4. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/algorithms/el2n_scorer.py +14 -12
  5. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/algorithms/kcenter_select.py +6 -4
  6. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/algorithms/margin_scorer.py +10 -13
  7. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/algorithms/sliding_window.py +4 -4
  8. datapruning-2.1.3/datapruning.egg-info/PKG-INFO +148 -0
  9. {datapruning-2.1.2 → datapruning-2.1.3}/pyproject.toml +1 -1
  10. datapruning-2.1.2/PKG-INFO +0 -81
  11. datapruning-2.1.2/README.md +0 -51
  12. datapruning-2.1.2/datapruning.egg-info/PKG-INFO +0 -81
  13. {datapruning-2.1.2 → datapruning-2.1.3}/LICENSE +0 -0
  14. {datapruning-2.1.2 → datapruning-2.1.3}/MANIFEST.in +0 -0
  15. {datapruning-2.1.2 → datapruning-2.1.3}/build_src/_core.c +0 -0
  16. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/algorithms/__init__.py +0 -0
  17. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/algorithms/base.py +0 -0
  18. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/algorithms/fusion_pipeline.py +0 -0
  19. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/algorithms/registry.py +0 -0
  20. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/engine/__init__.py +0 -0
  21. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/engine/benchmark.py +0 -0
  22. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/engine/explainability.py +0 -0
  23. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/engine/intelligence.py +0 -0
  24. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/engine/optimizer.py +0 -0
  25. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/engine/scanner.py +0 -0
  26. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/engine/strategy_display.py +0 -0
  27. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/engine/strategy_selector.py +0 -0
  28. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/multimodal/__init__.py +0 -0
  29. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/multimodal/clip_encoder.py +0 -0
  30. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/pipeline.py +0 -0
  31. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/reports/__init__.py +0 -0
  32. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/reports/exporter.py +0 -0
  33. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/__init__.py +0 -0
  34. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/benchmark/__init__.py +0 -0
  35. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/benchmark/compare.py +0 -0
  36. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/benchmark/evaluation.py +0 -0
  37. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/benchmark/synthetic.py +0 -0
  38. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/difficulty.py +0 -0
  39. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/embeddings/__init__.py +0 -0
  40. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/embeddings/torch_utils.py +0 -0
  41. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/fusion.py +0 -0
  42. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/noise.py +0 -0
  43. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/normalize.py +0 -0
  44. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/pipeline.py +0 -0
  45. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/redundancy.py +0 -0
  46. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/scores/__init__.py +0 -0
  47. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/scores/aum.py +0 -0
  48. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/scores/el2n.py +0 -0
  49. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/scores/forgetting.py +0 -0
  50. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/scores/grand.py +0 -0
  51. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/scores/margin.py +0 -0
  52. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/selection.py +0 -0
  53. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/selectors/__init__.py +0 -0
  54. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/selectors/facility_location.py +0 -0
  55. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/selectors/kcenter.py +0 -0
  56. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/selectors/out_of_fold.py +0 -0
  57. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/research_pruning/strategy.py +0 -0
  58. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning/sdk.py +0 -0
  59. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning.egg-info/SOURCES.txt +0 -0
  60. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning.egg-info/dependency_links.txt +0 -0
  61. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning.egg-info/requires.txt +0 -0
  62. {datapruning-2.1.2 → datapruning-2.1.3}/datapruning.egg-info/top_level.txt +0 -0
  63. {datapruning-2.1.2 → datapruning-2.1.3}/setup.cfg +0 -0
  64. {datapruning-2.1.2 → datapruning-2.1.3}/setup.py +0 -0
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: datapruning
3
+ Version: 2.1.3
4
+ Summary: Intelligent dataset optimization for cleaner, smaller training data
5
+ License: Proprietary
6
+ Project-URL: Homepage, https://www.datapruning.com
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: numpy>=1.24.0
21
+ Requires-Dist: pandas>=2.0.0
22
+ Requires-Dist: scikit-learn>=1.3.0
23
+ Provides-Extra: torch
24
+ Requires-Dist: torch>=2.0.0; extra == "torch"
25
+ Provides-Extra: clip
26
+ Requires-Dist: torch>=2.0.0; extra == "clip"
27
+ Requires-Dist: transformers>=4.30.0; extra == "clip"
28
+ Requires-Dist: pillow>=9.0.0; extra == "clip"
29
+ Dynamic: license-file
30
+
31
+ # DataPruning
32
+
33
+ Intelligent dataset optimization — reduces dataset size by selecting the most informative rows while preserving model quality.
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install datapruning
39
+ ```
40
+
41
+ For image/text multimodal support (CLIP encoding):
42
+
43
+ ```bash
44
+ pip install datapruning[clip]
45
+ ```
46
+
47
+ ## Quick Start
48
+
49
+ ### CSV / Tabular Data
50
+
51
+ ```python
52
+ import pandas as pd
53
+ from datapruning.sdk import DatasetEngine
54
+
55
+ df = pd.read_csv("dataset.csv")
56
+ engine = DatasetEngine(df, target_col="label")
57
+
58
+ # Analyze the dataset
59
+ analysis = engine.analyze()
60
+
61
+ # Get a recommendation
62
+ rec = engine.recommend()
63
+ print(f"Best method: {rec.display_name} ({rec.confidence}% confidence)")
64
+
65
+ # Optimize — keep 50% of most informative rows
66
+ result = engine.optimize(keep_ratio=0.5)
67
+ print(f"Kept {result['runtime_seconds']:.1f}s — {result['explainability']['rows_removed']} rows removed")
68
+
69
+ # Download the optimized dataset
70
+ result["optimized_df"].to_csv("optimized.csv", index=False)
71
+ ```
72
+
73
+ ### Image Datasets
74
+
75
+ ```python
76
+ from datapruning.sdk import DatasetEngine
77
+
78
+ # Create engine from a folder of images
79
+ engine = DatasetEngine.from_images(
80
+ folder_path="./photos",
81
+ labels=[0, 1, 0, 1, ...], # one label per image
82
+ keep_ratio=0.5,
83
+ )
84
+
85
+ # Analyze and optimize
86
+ analysis = engine.analyze()
87
+ result = engine.optimize(keep_ratio=0.5)
88
+ result["optimized_df"].to_csv("optimized_images.csv", index=False)
89
+ ```
90
+
91
+ ### Text Datasets
92
+
93
+ ```python
94
+ engine = DatasetEngine.from_texts(
95
+ texts=["label A sample", "label B sample", ...],
96
+ labels=[0, 1, 0, 1, ...],
97
+ )
98
+ result = engine.optimize(keep_ratio=0.5)
99
+ ```
100
+
101
+ ## Algorithms
102
+
103
+ DataPruning selects the best algorithm automatically based on dataset characteristics:
104
+
105
+ | Method | What it does | Best for |
106
+ |--------|-------------|----------|
107
+ | **Margin Optimization** | Analyzes classification confidence, keeps boundary samples | General tabular data |
108
+ | **Importance Scoring** | Measures sample difficulty via feature distances | Quick baseline, any dataset |
109
+ | **Diversity Selection** | Picks the most representative subset (K-Center) | High-dimensional data |
110
+ | **Noise Filtering** | Drops redundant and potentially mislabeled samples | Noisy/messy data |
111
+ | **Full Pipeline** | Combines all signals for maximum quality | Complex datasets |
112
+
113
+ ## Limits
114
+
115
+ - Minimum: 1,000 rows (tabular) or 10 images
116
+ - Maximum: 300,000 rows (tabular) or 1,000 images
117
+ - Supported image formats: JPG, PNG, BMP, GIF, TIFF, WebP
118
+
119
+ ## Requirements
120
+
121
+ - Python >= 3.10
122
+ - Pandas 2.0+
123
+ - NumPy 1.24+
124
+ - scikit-learn 1.3+
125
+
126
+ Optional (for image/text support):
127
+ - PyTorch 2.0+
128
+ - transformers 4.30+
129
+ - Pillow 9.0+
130
+
131
+ ## Features
132
+
133
+ - Runs locally — no data uploaded anywhere
134
+ - Auto-detects task type (classification/regression) and target column
135
+ - Auto-encodes categorical/string columns
136
+ - 5 optimization algorithms with automatic selection
137
+ - Preserves minority class balance
138
+ - CSV and image dataset support
139
+ - Pure Python — works on any platform
140
+
141
+ ## Links
142
+
143
+ - Website: [datapruning.com](https://www.datapruning.com)
144
+ - PyPI: [pypi.org/project/datapruning](https://pypi.org/project/datapruning/)
145
+
146
+ ## License
147
+
148
+ Proprietary. See LICENSE file.
@@ -0,0 +1,118 @@
1
+ # DataPruning
2
+
3
+ Intelligent dataset optimization — reduces dataset size by selecting the most informative rows while preserving model quality.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install datapruning
9
+ ```
10
+
11
+ For image/text multimodal support (CLIP encoding):
12
+
13
+ ```bash
14
+ pip install datapruning[clip]
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ### CSV / Tabular Data
20
+
21
+ ```python
22
+ import pandas as pd
23
+ from datapruning.sdk import DatasetEngine
24
+
25
+ df = pd.read_csv("dataset.csv")
26
+ engine = DatasetEngine(df, target_col="label")
27
+
28
+ # Analyze the dataset
29
+ analysis = engine.analyze()
30
+
31
+ # Get a recommendation
32
+ rec = engine.recommend()
33
+ print(f"Best method: {rec.display_name} ({rec.confidence}% confidence)")
34
+
35
+ # Optimize — keep 50% of most informative rows
36
+ result = engine.optimize(keep_ratio=0.5)
37
+ print(f"Kept {result['runtime_seconds']:.1f}s — {result['explainability']['rows_removed']} rows removed")
38
+
39
+ # Download the optimized dataset
40
+ result["optimized_df"].to_csv("optimized.csv", index=False)
41
+ ```
42
+
43
+ ### Image Datasets
44
+
45
+ ```python
46
+ from datapruning.sdk import DatasetEngine
47
+
48
+ # Create engine from a folder of images
49
+ engine = DatasetEngine.from_images(
50
+ folder_path="./photos",
51
+ labels=[0, 1, 0, 1, ...], # one label per image
52
+ keep_ratio=0.5,
53
+ )
54
+
55
+ # Analyze and optimize
56
+ analysis = engine.analyze()
57
+ result = engine.optimize(keep_ratio=0.5)
58
+ result["optimized_df"].to_csv("optimized_images.csv", index=False)
59
+ ```
60
+
61
+ ### Text Datasets
62
+
63
+ ```python
64
+ engine = DatasetEngine.from_texts(
65
+ texts=["label A sample", "label B sample", ...],
66
+ labels=[0, 1, 0, 1, ...],
67
+ )
68
+ result = engine.optimize(keep_ratio=0.5)
69
+ ```
70
+
71
+ ## Algorithms
72
+
73
+ DataPruning selects the best algorithm automatically based on dataset characteristics:
74
+
75
+ | Method | What it does | Best for |
76
+ |--------|-------------|----------|
77
+ | **Margin Optimization** | Analyzes classification confidence, keeps boundary samples | General tabular data |
78
+ | **Importance Scoring** | Measures sample difficulty via feature distances | Quick baseline, any dataset |
79
+ | **Diversity Selection** | Picks the most representative subset (K-Center) | High-dimensional data |
80
+ | **Noise Filtering** | Drops redundant and potentially mislabeled samples | Noisy/messy data |
81
+ | **Full Pipeline** | Combines all signals for maximum quality | Complex datasets |
82
+
83
+ ## Limits
84
+
85
+ - Minimum: 1,000 rows (tabular) or 10 images
86
+ - Maximum: 300,000 rows (tabular) or 1,000 images
87
+ - Supported image formats: JPG, PNG, BMP, GIF, TIFF, WebP
88
+
89
+ ## Requirements
90
+
91
+ - Python >= 3.10
92
+ - Pandas 2.0+
93
+ - NumPy 1.24+
94
+ - scikit-learn 1.3+
95
+
96
+ Optional (for image/text support):
97
+ - PyTorch 2.0+
98
+ - transformers 4.30+
99
+ - Pillow 9.0+
100
+
101
+ ## Features
102
+
103
+ - Runs locally — no data uploaded anywhere
104
+ - Auto-detects task type (classification/regression) and target column
105
+ - Auto-encodes categorical/string columns
106
+ - 5 optimization algorithms with automatic selection
107
+ - Preserves minority class balance
108
+ - CSV and image dataset support
109
+ - Pure Python — works on any platform
110
+
111
+ ## Links
112
+
113
+ - Website: [datapruning.com](https://www.datapruning.com)
114
+ - PyPI: [pypi.org/project/datapruning](https://pypi.org/project/datapruning/)
115
+
116
+ ## License
117
+
118
+ Proprietary. See LICENSE file.
@@ -5,6 +5,8 @@ import pandas as pd
5
5
  from . import pipeline
6
6
  from .sdk import DatasetEngine
7
7
 
8
+ __all__ = ["DatasetEngine", "Pruner", "prune_dataframe"]
9
+
8
10
  logger = logging.getLogger(__name__)
9
11
 
10
12
  MIN_ROWS = 1000
@@ -16,31 +16,33 @@ class EL2NScorerOptimizer(BaseOptimizer):
16
16
  def fit(self, X: pd.DataFrame, y: pd.Series) -> "EL2NScorerOptimizer":
17
17
  X_arr = X.values.astype(np.float64)
18
18
  y_arr = y.values
19
- feat_norms = np.linalg.norm(X_arr, axis=1)
20
- feat_norms_normed = (feat_norms - feat_norms.min()) / max(feat_norms.max() - feat_norms.min(), 1e-8)
21
19
  classes = np.unique(y_arr)
22
- centroid_scores = np.zeros(len(y_arr), dtype=np.float64)
20
+ scores = np.zeros(len(y_arr), dtype=np.float64)
23
21
  for cls in classes:
24
22
  cls_mask = y_arr == cls
25
23
  centroid = X_arr[cls_mask].mean(axis=0)
26
24
  dists = np.linalg.norm(X_arr - centroid, axis=1)
27
- dists_normed = (dists - dists.min()) / max(dists.max() - dists.min(), 1e-8)
28
- centroid_scores = np.maximum(centroid_scores, dists_normed)
29
- combined = 0.5 * feat_norms_normed + 0.5 * centroid_scores
30
- self._scores = pd.Series(combined, index=y.index)
25
+ scores = np.maximum(scores, dists)
26
+ self._scores = pd.Series(scores, index=y.index)
31
27
  return self
32
28
 
33
29
  def _select_rows(self, X: pd.DataFrame, y: pd.Series, keep_ratio: float) -> pd.Index:
34
30
  if self._scores is None:
35
31
  self.fit(X, y)
32
+ classes = y.unique()
33
+ if len(classes) < 2:
34
+ n_target = max(1, int(len(y) * keep_ratio))
35
+ return y.sample(n=n_target, random_state=42).index
36
36
  minority_class = y.value_counts().idxmin()
37
37
  minority_idx = y[y == minority_class].index
38
38
  majority_idx = y[y != minority_class].index
39
- n_total_target = int(len(y) * keep_ratio)
40
- n_majority_target = max(n_total_target - len(minority_idx), 0)
39
+ n_total_target = max(1, int(len(y) * keep_ratio))
40
+ n_minority = min(len(minority_idx), int(n_total_target * 0.8))
41
+ n_majority_target = max(n_total_target - n_minority, 0)
41
42
  majority_scores = self._scores.loc[majority_idx].sort_values(ascending=False)
42
43
  kept_majority_idx = majority_scores.index[:n_majority_target]
43
- return minority_idx.append(kept_majority_idx)
44
+ kept_minority_idx = minority_idx[:n_minority]
45
+ return kept_minority_idx.append(kept_majority_idx)
44
46
 
45
47
  def why_selected(self) -> str:
46
48
  return ("Measures how difficult each sample is for the model to classify by analyzing "
@@ -62,5 +64,5 @@ class EL2NScorerOptimizer(BaseOptimizer):
62
64
  if task_type == "regression":
63
65
  return 0.0
64
66
  if n_rows < 200:
65
- return 0.1
66
- return 0.5
67
+ return 0.2
68
+ return 0.4
@@ -48,9 +48,11 @@ class KCenterSelectOptimizer(BaseOptimizer):
48
48
  n_cols = scan.get("columns", 0)
49
49
 
50
50
  if task_type == "regression":
51
- return 0.2
51
+ return 0.3
52
+ if n_rows < 500:
53
+ return 0.6
52
54
  if n_cols > n_rows:
53
- return 0.8
55
+ return 0.9
54
56
  if n_cols > 50:
55
- return 0.65
56
- return 0.4
57
+ return 0.85
58
+ return 0.8
@@ -37,16 +37,18 @@ class MarginScorerOptimizer(BaseOptimizer):
37
37
  self.fit(X, y)
38
38
  classes = y.unique()
39
39
  if len(classes) < 2:
40
- n_target = int(len(y) * keep_ratio)
41
- return y.nlargest(n_target).index
40
+ n_target = max(1, int(len(y) * keep_ratio))
41
+ return y.sample(n=n_target, random_state=42).index
42
42
  minority_class = y.value_counts().idxmin()
43
43
  minority_idx = y[y == minority_class].index
44
44
  majority_idx = y[y != minority_class].index
45
- n_total_target = int(len(y) * keep_ratio)
46
- n_majority_target = max(n_total_target - len(minority_idx), 0)
47
- majority_scores = self._scores.loc[majority_idx].sort_values(ascending=False)
45
+ n_total_target = max(1, int(len(y) * keep_ratio))
46
+ n_minority = min(len(minority_idx), int(n_total_target * 0.8))
47
+ n_majority_target = max(n_total_target - n_minority, 0)
48
+ majority_scores = self._scores.loc[majority_idx].sort_values(ascending=True)
48
49
  kept_majority_idx = majority_scores.index[:n_majority_target]
49
- return minority_idx.append(kept_majority_idx)
50
+ kept_minority_idx = minority_idx[:n_minority]
51
+ return kept_minority_idx.append(kept_majority_idx)
50
52
 
51
53
  def why_selected(self) -> str:
52
54
  return ("Analyzes how confidently each data point is classified, keeping the most "
@@ -64,14 +66,9 @@ class MarginScorerOptimizer(BaseOptimizer):
64
66
  scan = analysis.get("scan", analysis)
65
67
  task_type = scan.get("task_type", "unknown")
66
68
  n_rows = scan.get("rows", 0)
67
- n_cols = scan.get("columns", 0)
68
69
 
69
70
  if task_type == "regression":
70
71
  return 0.0
71
72
  if n_rows < 500:
72
- return 0.1
73
- if n_rows > 200_000:
74
- return 0.6
75
- if n_cols > 100:
76
- return 0.7
77
- return 0.85
73
+ return 0.2
74
+ return 0.3
@@ -40,8 +40,8 @@ class SlidingWindowOptimizer(BaseOptimizer):
40
40
  low_pct = max(0, (1 - keep_ratio) * 100 / 2)
41
41
  high_pct = min(100, 100 - low_pct)
42
42
  if len(classes) < 2:
43
- n_target = int(len(y) * keep_ratio)
44
- return y.nlargest(n_target).index
43
+ n_target = max(1, int(len(y) * keep_ratio))
44
+ return y.sample(n=n_target, random_state=42).index
45
45
  selected = sliding_window_select(
46
46
  self._scores,
47
47
  low_percentile=low_pct,
@@ -53,10 +53,10 @@ class SlidingWindowOptimizer(BaseOptimizer):
53
53
  minority_idx = y[y == minority_class].index
54
54
  selected_idx = X.index[selected]
55
55
  all_idx = selected_idx.union(minority_idx).unique()
56
- n_target = int(len(y) * keep_ratio)
56
+ n_target = max(1, int(len(y) * keep_ratio))
57
57
  if len(all_idx) > n_target:
58
58
  scores_at_idx = pd.Series(self._scores, index=X.index).loc[all_idx]
59
- all_idx = scores_at_idx.sort_values(ascending=False).index[:n_target]
59
+ all_idx = scores_at_idx.sort_values(ascending=True).index[:n_target]
60
60
  return all_idx
61
61
 
62
62
  def why_selected(self) -> str:
@@ -0,0 +1,148 @@
1
+ Metadata-Version: 2.4
2
+ Name: datapruning
3
+ Version: 2.1.3
4
+ Summary: Intelligent dataset optimization for cleaner, smaller training data
5
+ License: Proprietary
6
+ Project-URL: Homepage, https://www.datapruning.com
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: numpy>=1.24.0
21
+ Requires-Dist: pandas>=2.0.0
22
+ Requires-Dist: scikit-learn>=1.3.0
23
+ Provides-Extra: torch
24
+ Requires-Dist: torch>=2.0.0; extra == "torch"
25
+ Provides-Extra: clip
26
+ Requires-Dist: torch>=2.0.0; extra == "clip"
27
+ Requires-Dist: transformers>=4.30.0; extra == "clip"
28
+ Requires-Dist: pillow>=9.0.0; extra == "clip"
29
+ Dynamic: license-file
30
+
31
+ # DataPruning
32
+
33
+ Intelligent dataset optimization — reduces dataset size by selecting the most informative rows while preserving model quality.
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ pip install datapruning
39
+ ```
40
+
41
+ For image/text multimodal support (CLIP encoding):
42
+
43
+ ```bash
44
+ pip install datapruning[clip]
45
+ ```
46
+
47
+ ## Quick Start
48
+
49
+ ### CSV / Tabular Data
50
+
51
+ ```python
52
+ import pandas as pd
53
+ from datapruning.sdk import DatasetEngine
54
+
55
+ df = pd.read_csv("dataset.csv")
56
+ engine = DatasetEngine(df, target_col="label")
57
+
58
+ # Analyze the dataset
59
+ analysis = engine.analyze()
60
+
61
+ # Get a recommendation
62
+ rec = engine.recommend()
63
+ print(f"Best method: {rec.display_name} ({rec.confidence}% confidence)")
64
+
65
+ # Optimize — keep 50% of most informative rows
66
+ result = engine.optimize(keep_ratio=0.5)
67
+ print(f"Kept {result['runtime_seconds']:.1f}s — {result['explainability']['rows_removed']} rows removed")
68
+
69
+ # Download the optimized dataset
70
+ result["optimized_df"].to_csv("optimized.csv", index=False)
71
+ ```
72
+
73
+ ### Image Datasets
74
+
75
+ ```python
76
+ from datapruning.sdk import DatasetEngine
77
+
78
+ # Create engine from a folder of images
79
+ engine = DatasetEngine.from_images(
80
+ folder_path="./photos",
81
+ labels=[0, 1, 0, 1, ...], # one label per image
82
+ keep_ratio=0.5,
83
+ )
84
+
85
+ # Analyze and optimize
86
+ analysis = engine.analyze()
87
+ result = engine.optimize(keep_ratio=0.5)
88
+ result["optimized_df"].to_csv("optimized_images.csv", index=False)
89
+ ```
90
+
91
+ ### Text Datasets
92
+
93
+ ```python
94
+ engine = DatasetEngine.from_texts(
95
+ texts=["label A sample", "label B sample", ...],
96
+ labels=[0, 1, 0, 1, ...],
97
+ )
98
+ result = engine.optimize(keep_ratio=0.5)
99
+ ```
100
+
101
+ ## Algorithms
102
+
103
+ DataPruning selects the best algorithm automatically based on dataset characteristics:
104
+
105
+ | Method | What it does | Best for |
106
+ |--------|-------------|----------|
107
+ | **Margin Optimization** | Analyzes classification confidence, keeps boundary samples | General tabular data |
108
+ | **Importance Scoring** | Measures sample difficulty via feature distances | Quick baseline, any dataset |
109
+ | **Diversity Selection** | Picks the most representative subset (K-Center) | High-dimensional data |
110
+ | **Noise Filtering** | Drops redundant and potentially mislabeled samples | Noisy/messy data |
111
+ | **Full Pipeline** | Combines all signals for maximum quality | Complex datasets |
112
+
113
+ ## Limits
114
+
115
+ - Minimum: 1,000 rows (tabular) or 10 images
116
+ - Maximum: 300,000 rows (tabular) or 1,000 images
117
+ - Supported image formats: JPG, PNG, BMP, GIF, TIFF, WebP
118
+
119
+ ## Requirements
120
+
121
+ - Python >= 3.10
122
+ - Pandas 2.0+
123
+ - NumPy 1.24+
124
+ - scikit-learn 1.3+
125
+
126
+ Optional (for image/text support):
127
+ - PyTorch 2.0+
128
+ - transformers 4.30+
129
+ - Pillow 9.0+
130
+
131
+ ## Features
132
+
133
+ - Runs locally — no data uploaded anywhere
134
+ - Auto-detects task type (classification/regression) and target column
135
+ - Auto-encodes categorical/string columns
136
+ - 5 optimization algorithms with automatic selection
137
+ - Preserves minority class balance
138
+ - CSV and image dataset support
139
+ - Pure Python — works on any platform
140
+
141
+ ## Links
142
+
143
+ - Website: [datapruning.com](https://www.datapruning.com)
144
+ - PyPI: [pypi.org/project/datapruning](https://pypi.org/project/datapruning/)
145
+
146
+ ## License
147
+
148
+ Proprietary. See LICENSE file.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "datapruning"
7
- version = "2.1.2"
7
+ version = "2.1.3"
8
8
  description = "Intelligent dataset optimization for cleaner, smaller training data"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,81 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: datapruning
3
- Version: 2.1.2
4
- Summary: Intelligent dataset optimization for cleaner, smaller training data
5
- License: Proprietary
6
- Project-URL: Homepage, https://www.datapruning.com
7
- Classifier: Development Status :: 4 - Beta
8
- Classifier: Intended Audience :: Developers
9
- Classifier: Intended Audience :: Science/Research
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Programming Language :: Python :: 3.13
15
- Classifier: Programming Language :: Python :: 3.14
16
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
- Requires-Python: >=3.10
18
- Description-Content-Type: text/markdown
19
- License-File: LICENSE
20
- Requires-Dist: numpy>=1.24.0
21
- Requires-Dist: pandas>=2.0.0
22
- Requires-Dist: scikit-learn>=1.3.0
23
- Provides-Extra: torch
24
- Requires-Dist: torch>=2.0.0; extra == "torch"
25
- Provides-Extra: clip
26
- Requires-Dist: torch>=2.0.0; extra == "clip"
27
- Requires-Dist: transformers>=4.30.0; extra == "clip"
28
- Requires-Dist: pillow>=9.0.0; extra == "clip"
29
- Dynamic: license-file
30
-
31
- # DataPruning
32
-
33
- Intelligent dataset pruning for ML — reduces dataset size by selecting the most informative rows.
34
-
35
- ## Installation
36
-
37
- ```bash
38
- pip install datapruning
39
- ```
40
-
41
- **Note:** PyTorch (~2 GB) is a required dependency.
42
-
43
- ## Requirements
44
-
45
- - Python >= 3.10
46
- - PyTorch 2.0+
47
- - Pandas 2.0+
48
- - NumPy 1.24+
49
-
50
- ## Limits
51
-
52
- - Minimum: 1,000 rows per dataset
53
- - Maximum: 300,000 rows per dataset
54
-
55
- ## Usage
56
-
57
- ```python
58
- import pandas as pd
59
- from datapruning import Pruner
60
-
61
- df = pd.read_csv("dataset.csv")
62
- p = Pruner(df)
63
- filtered = p.prune(target_col="label", keep_ratio=0.5)
64
-
65
- print(f"Kept {len(filtered)} / {len(df)} rows")
66
- ```
67
-
68
- ## Features
69
-
70
- - Runs locally, no data upload
71
- - Pre-training dataset optimization
72
- - Pandas DataFrame input / output
73
- - Compiled processing module
74
-
75
- ## Links
76
-
77
- - Website: [datapruning.com](https://www.datapruning.com)
78
-
79
- ## License
80
-
81
- Proprietary. See LICENSE file.
@@ -1,51 +0,0 @@
1
- # DataPruning
2
-
3
- Intelligent dataset pruning for ML — reduces dataset size by selecting the most informative rows.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- pip install datapruning
9
- ```
10
-
11
- **Note:** PyTorch (~2 GB) is a required dependency.
12
-
13
- ## Requirements
14
-
15
- - Python >= 3.10
16
- - PyTorch 2.0+
17
- - Pandas 2.0+
18
- - NumPy 1.24+
19
-
20
- ## Limits
21
-
22
- - Minimum: 1,000 rows per dataset
23
- - Maximum: 300,000 rows per dataset
24
-
25
- ## Usage
26
-
27
- ```python
28
- import pandas as pd
29
- from datapruning import Pruner
30
-
31
- df = pd.read_csv("dataset.csv")
32
- p = Pruner(df)
33
- filtered = p.prune(target_col="label", keep_ratio=0.5)
34
-
35
- print(f"Kept {len(filtered)} / {len(df)} rows")
36
- ```
37
-
38
- ## Features
39
-
40
- - Runs locally, no data upload
41
- - Pre-training dataset optimization
42
- - Pandas DataFrame input / output
43
- - Compiled processing module
44
-
45
- ## Links
46
-
47
- - Website: [datapruning.com](https://www.datapruning.com)
48
-
49
- ## License
50
-
51
- Proprietary. See LICENSE file.
@@ -1,81 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: datapruning
3
- Version: 2.1.2
4
- Summary: Intelligent dataset optimization for cleaner, smaller training data
5
- License: Proprietary
6
- Project-URL: Homepage, https://www.datapruning.com
7
- Classifier: Development Status :: 4 - Beta
8
- Classifier: Intended Audience :: Developers
9
- Classifier: Intended Audience :: Science/Research
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.10
12
- Classifier: Programming Language :: Python :: 3.11
13
- Classifier: Programming Language :: Python :: 3.12
14
- Classifier: Programming Language :: Python :: 3.13
15
- Classifier: Programming Language :: Python :: 3.14
16
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
- Requires-Python: >=3.10
18
- Description-Content-Type: text/markdown
19
- License-File: LICENSE
20
- Requires-Dist: numpy>=1.24.0
21
- Requires-Dist: pandas>=2.0.0
22
- Requires-Dist: scikit-learn>=1.3.0
23
- Provides-Extra: torch
24
- Requires-Dist: torch>=2.0.0; extra == "torch"
25
- Provides-Extra: clip
26
- Requires-Dist: torch>=2.0.0; extra == "clip"
27
- Requires-Dist: transformers>=4.30.0; extra == "clip"
28
- Requires-Dist: pillow>=9.0.0; extra == "clip"
29
- Dynamic: license-file
30
-
31
- # DataPruning
32
-
33
- Intelligent dataset pruning for ML — reduces dataset size by selecting the most informative rows.
34
-
35
- ## Installation
36
-
37
- ```bash
38
- pip install datapruning
39
- ```
40
-
41
- **Note:** PyTorch (~2 GB) is a required dependency.
42
-
43
- ## Requirements
44
-
45
- - Python >= 3.10
46
- - PyTorch 2.0+
47
- - Pandas 2.0+
48
- - NumPy 1.24+
49
-
50
- ## Limits
51
-
52
- - Minimum: 1,000 rows per dataset
53
- - Maximum: 300,000 rows per dataset
54
-
55
- ## Usage
56
-
57
- ```python
58
- import pandas as pd
59
- from datapruning import Pruner
60
-
61
- df = pd.read_csv("dataset.csv")
62
- p = Pruner(df)
63
- filtered = p.prune(target_col="label", keep_ratio=0.5)
64
-
65
- print(f"Kept {len(filtered)} / {len(df)} rows")
66
- ```
67
-
68
- ## Features
69
-
70
- - Runs locally, no data upload
71
- - Pre-training dataset optimization
72
- - Pandas DataFrame input / output
73
- - Compiled processing module
74
-
75
- ## Links
76
-
77
- - Website: [datapruning.com](https://www.datapruning.com)
78
-
79
- ## License
80
-
81
- Proprietary. See LICENSE file.
File without changes
File without changes
File without changes
File without changes