dataleaks 0.1.0__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 (59) hide show
  1. dataleaks-0.1.0/LICENSE +21 -0
  2. dataleaks-0.1.0/PKG-INFO +700 -0
  3. dataleaks-0.1.0/README.md +684 -0
  4. dataleaks-0.1.0/dataleaks/__init__.py +3 -0
  5. dataleaks-0.1.0/dataleaks/api.py +67 -0
  6. dataleaks-0.1.0/dataleaks/cli.py +276 -0
  7. dataleaks-0.1.0/dataleaks/detectors/__init__.py +0 -0
  8. dataleaks-0.1.0/dataleaks/detectors/cross_dataset/__init__.py +0 -0
  9. dataleaks-0.1.0/dataleaks/detectors/cross_dataset/overlap.py +137 -0
  10. dataleaks-0.1.0/dataleaks/detectors/feature/__init__.py +0 -0
  11. dataleaks-0.1.0/dataleaks/detectors/feature/identifier.py +238 -0
  12. dataleaks-0.1.0/dataleaks/detectors/feature/suspicious.py +278 -0
  13. dataleaks-0.1.0/dataleaks/detectors/feature/target_encoding.py +88 -0
  14. dataleaks-0.1.0/dataleaks/detectors/preprocessing/__init__.py +0 -0
  15. dataleaks-0.1.0/dataleaks/detectors/preprocessing/contamination.py +94 -0
  16. dataleaks-0.1.0/dataleaks/detectors/preprocessing/fit_before_split.py +83 -0
  17. dataleaks-0.1.0/dataleaks/detectors/split/__init__.py +0 -0
  18. dataleaks-0.1.0/dataleaks/detectors/split/duplicates.py +82 -0
  19. dataleaks-0.1.0/dataleaks/detectors/split/near_duplicates.py +146 -0
  20. dataleaks-0.1.0/dataleaks/detectors/split/overlap.py +254 -0
  21. dataleaks-0.1.0/dataleaks/detectors/target/__init__.py +0 -0
  22. dataleaks-0.1.0/dataleaks/detectors/target/derived.py +200 -0
  23. dataleaks-0.1.0/dataleaks/detectors/target/direct.py +60 -0
  24. dataleaks-0.1.0/dataleaks/detectors/target/statistical.py +104 -0
  25. dataleaks-0.1.0/dataleaks/detectors/temporal/__init__.py +0 -0
  26. dataleaks-0.1.0/dataleaks/detectors/temporal/future_features.py +784 -0
  27. dataleaks-0.1.0/dataleaks/detectors/temporal/parsing.py +265 -0
  28. dataleaks-0.1.0/dataleaks/detectors/temporal/time_order.py +95 -0
  29. dataleaks-0.1.0/dataleaks/engine/__init__.py +7 -0
  30. dataleaks-0.1.0/dataleaks/engine/aggregator.py +288 -0
  31. dataleaks-0.1.0/dataleaks/engine/defaults.py +341 -0
  32. dataleaks-0.1.0/dataleaks/engine/detector.py +16 -0
  33. dataleaks-0.1.0/dataleaks/engine/registry.py +97 -0
  34. dataleaks-0.1.0/dataleaks/engine/runner.py +75 -0
  35. dataleaks-0.1.0/dataleaks/recommendations/__init__.py +0 -0
  36. dataleaks-0.1.0/dataleaks/recommendations/fixes.py +42 -0
  37. dataleaks-0.1.0/dataleaks/recommendations/recommendations.py +27 -0
  38. dataleaks-0.1.0/dataleaks/reporting/__init__.py +5 -0
  39. dataleaks-0.1.0/dataleaks/reporting/console.py +93 -0
  40. dataleaks-0.1.0/dataleaks/reporting/json.py +114 -0
  41. dataleaks-0.1.0/dataleaks/reporting/report.py +224 -0
  42. dataleaks-0.1.0/dataleaks/reporting/summary.py +37 -0
  43. dataleaks-0.1.0/dataleaks/schemas/__init__.py +7 -0
  44. dataleaks-0.1.0/dataleaks/schemas/config.py +31 -0
  45. dataleaks-0.1.0/dataleaks/schemas/dataset.py +93 -0
  46. dataleaks-0.1.0/dataleaks/schemas/execution.py +86 -0
  47. dataleaks-0.1.0/dataleaks/schemas/finding.py +29 -0
  48. dataleaks-0.1.0/dataleaks/scoring/__init__.py +0 -0
  49. dataleaks-0.1.0/dataleaks/scoring/confidence.py +49 -0
  50. dataleaks-0.1.0/dataleaks/scoring/risk.py +76 -0
  51. dataleaks-0.1.0/dataleaks/scoring/severity.py +64 -0
  52. dataleaks-0.1.0/dataleaks.egg-info/PKG-INFO +700 -0
  53. dataleaks-0.1.0/dataleaks.egg-info/SOURCES.txt +57 -0
  54. dataleaks-0.1.0/dataleaks.egg-info/dependency_links.txt +1 -0
  55. dataleaks-0.1.0/dataleaks.egg-info/entry_points.txt +2 -0
  56. dataleaks-0.1.0/dataleaks.egg-info/requires.txt +6 -0
  57. dataleaks-0.1.0/dataleaks.egg-info/top_level.txt +1 -0
  58. dataleaks-0.1.0/pyproject.toml +35 -0
  59. dataleaks-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kavya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,700 @@
1
+ Metadata-Version: 2.4
2
+ Name: dataleaks
3
+ Version: 0.1.0
4
+ Summary: Automatic data leakage detection for machine learning workflows
5
+ Author: Kavya Rajput
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: pandas>=1.5
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest>=7; extra == "dev"
13
+ Requires-Dist: pytest-cov>=4; extra == "dev"
14
+ Requires-Dist: ruff>=0.6; extra == "dev"
15
+ Dynamic: license-file
16
+
17
+ <div align="center">
18
+
19
+ # ๐Ÿ” DataLeaks
20
+
21
+ ### Automatic Data Leakage Detection for Machine Learning
22
+
23
+ **Find leakage before it silently invalidates your model.**
24
+
25
+ [![PyPI](https://img.shields.io/pypi/v/dataleaks?style=for-the-badge&logo=pypi)](https://pypi.org/project/dataleaks/)
26
+ [![Python](https://img.shields.io/pypi/pyversions/dataleaks?style=for-the-badge&logo=python)](https://pypi.org/project/dataleaks/)
27
+ [![Tests](https://img.shields.io/badge/tests-521%20passed-success?style=for-the-badge)](#testing)
28
+ [![License](https://img.shields.io/badge/license-MIT-blue?style=for-the-badge)](LICENSE)
29
+
30
+ **Dataset โ†’ Detection โ†’ Findings โ†’ Risk โ†’ Recommendations**
31
+
32
+ </div>
33
+
34
+ ---
35
+
36
+ ## ๐Ÿšจ Why DataLeaks?
37
+
38
+ A machine learning model can achieve excellent validation performance while
39
+ being fundamentally unreliable because information from the target, future,
40
+ evaluation data, or downstream workflow has leaked into the training process.
41
+
42
+ Common examples:
43
+
44
+ - A feature directly contains the target.
45
+ - A feature is mathematically derived from the target.
46
+ - The same entities appear in train and test.
47
+ - A feature contains information from the future.
48
+ - Preprocessing is fitted on the complete dataset before splitting.
49
+ - Training preprocessing is contaminated by held-out data.
50
+ - An identifier creates cross-split information leakage.
51
+ - A post-outcome feature is accidentally used for prediction.
52
+
53
+ **DataLeaks automatically analyzes these patterns and converts suspicious
54
+ signals into structured, explainable findings.**
55
+
56
+ ---
57
+
58
+ # โœจ Features
59
+
60
+ | Capability | What DataLeaks Checks |
61
+ |---|---|
62
+ | ๐ŸŽฏ **Target Leakage** | Direct, statistical, and derived-target relationships |
63
+ | ๐Ÿ”€ **Split Leakage** | Duplicate, near-duplicate, and overlapping values |
64
+ | ๐Ÿ†” **Identifier Leakage** | Identifier-like features and cross-split entity overlap |
65
+ | ๐Ÿ•ต๏ธ **Suspicious Features** | Strong feature-target relationships and semantic signals |
66
+ | โฑ๏ธ **Temporal Leakage** | Future timestamps and chronological ordering |
67
+ | ๐Ÿšง **Preprocessing Leakage** | Fit-before-split and held-out-data contamination |
68
+ | ๐ŸŒ **Cross-Dataset Leakage** | Overlap between reference datasets |
69
+ | ๐Ÿงช **Schema Validation** | Missing columns, dtype mismatches, and target validation |
70
+ | ๐Ÿ“Š **Risk Scoring** | Severity ร— confidence based risk assessment |
71
+ | ๐Ÿ’ก **Recommendations** | Actionable remediation guidance |
72
+ | ๐Ÿ“‹ **Reporting** | Console and machine-readable JSON |
73
+ | โš™๏ธ **Execution Tracking** | Completed, failed, and skipped detectors |
74
+ | ๐Ÿ **Python API** | Programmatic integration |
75
+ | ๐Ÿ’ป **CLI** | One-command dataset analysis |
76
+
77
+ ---
78
+
79
+ # ๐Ÿ“ฆ Installation
80
+
81
+ Install DataLeaks directly from PyPI:
82
+
83
+ ```bash
84
+ pip install dataleaks
85
+
86
+ โšก Quick Start
87
+ import pandas as pd
88
+
89
+ from dataleaks import DataLeaks
90
+
91
+ df = pd.read_csv("train.csv")
92
+
93
+ report = DataLeaks(
94
+ df,
95
+ target="target",
96
+ ).run()
97
+
98
+ print("Risk:", report.risk_level)
99
+ print("Score:", report.risk_score)
100
+ print("Findings:", report.finding_count)
101
+
102
+ for finding in report.findings:
103
+ print(
104
+ finding.detector,
105
+ finding.severity,
106
+ finding.explanation,
107
+ )
108
+
109
+ The workflow is intentionally simple:
110
+
111
+ Dataset
112
+ โ†“
113
+ DataLeaks(...)
114
+ โ†“
115
+ .run()
116
+ โ†“
117
+ LeakageReport
118
+ ๐Ÿ’ป CLI
119
+
120
+ DataLeaks can also be used directly from the terminal.
121
+
122
+ Basic analysis
123
+ dataleaks train.csv --target target
124
+ Train / validation / test
125
+ dataleaks train.csv --target target --validation validation.csv --test test.csv
126
+ JSON output
127
+ dataleaks train.csv --target target --output json
128
+ ๐ŸŽฏ Target Leakage
129
+
130
+ Target leakage occurs when a feature contains information that directly or
131
+ indirectly reveals the prediction target.
132
+
133
+ DataLeaks checks multiple forms of target leakage.
134
+
135
+ Direct leakage
136
+ target = churn
137
+ leaky_feature = churn
138
+
139
+ A feature that directly reproduces the target is a strong leakage signal.
140
+
141
+ Statistical leakage
142
+
143
+ Extremely strong numerical relationships between a feature and the target are
144
+ flagged for investigation.
145
+
146
+ Derived-target leakage
147
+
148
+ DataLeaks can identify deterministic relationships such as:
149
+
150
+ leaky_feature = 1 ร— target + 0
151
+
152
+ These relationships can make model performance appear unrealistically strong.
153
+
154
+ ๐Ÿ”€ Split Leakage
155
+
156
+ DataLeaks analyzes relationships between training, validation, and test data.
157
+
158
+ It checks for:
159
+
160
+ Exact duplicate rows
161
+ Near-duplicate rows
162
+ Overlapping values
163
+ Entity overlap
164
+ Suspicious identifier overlap
165
+
166
+ Example:
167
+
168
+ TRAIN TEST
169
+
170
+ customer_id customer_id
171
+ CUST1001 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ CUST1001
172
+ CUST1002 โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ CUST1002
173
+ CUST1003 CUST1007
174
+
175
+ When the same real-world entities appear across training and evaluation data,
176
+ model evaluation can become unreliable.
177
+
178
+ ๐Ÿ†” Identifier Leakage
179
+
180
+ Identifiers can become leakage channels when entities overlap across dataset
181
+ boundaries.
182
+
183
+ Examples include:
184
+
185
+ customer_id
186
+ user_id
187
+ patient_id
188
+ transaction_id
189
+ device_id
190
+
191
+ DataLeaks intentionally does not treat high cardinality alone as proof of
192
+ identifier leakage.
193
+
194
+ Identifier-like semantics and explicit metadata are used to make this detection
195
+ more conservative.
196
+
197
+ ๐Ÿ•ต๏ธ Suspicious & Post-Outcome Features
198
+
199
+ Some features contain information that only becomes available after the event
200
+ being predicted.
201
+
202
+ Examples include:
203
+
204
+ future_purchase_value
205
+ post_outcome_refund
206
+ after_event_status
207
+ forecast_revenue
208
+ subsequent_transaction
209
+
210
+ DataLeaks combines statistical evidence with semantic signals to identify
211
+ features that deserve investigation.
212
+
213
+ Example:
214
+
215
+ Prediction
216
+ โ”‚
217
+ โ”œโ”€โ”€โ–บ Model Input
218
+ โ”‚
219
+ โ””โ”€โ”€โ–บ Refund Processed
220
+ โ†‘
221
+ happens later
222
+
223
+ Using a later event as an input for an earlier prediction introduces leakage.
224
+
225
+ โฑ๏ธ Temporal Leakage
226
+
227
+ Temporal leakage occurs when information that would not have been available at
228
+ prediction time becomes part of the model input.
229
+
230
+ DataLeaks can detect:
231
+
232
+ Invalid timestamps
233
+ Missing or unparsable timestamps
234
+ Chronological ordering problems
235
+ Feature timestamps occurring after prediction timestamps
236
+ Future-feature relationships
237
+ Conditional timestamp presence
238
+ Chronological validation
239
+ dataleaks train.csv --target target --time-column event_time
240
+ Future-feature detection
241
+ dataleaks train.csv --target target \
242
+ --prediction-time-column prediction_time \
243
+ --feature-time-columns signup_time outcome_time
244
+
245
+ DataLeaks compares feature timestamps with the prediction timestamp to identify
246
+ information that would not have been available when the prediction was made.
247
+
248
+ Conditional timestamps
249
+
250
+ Some timestamp fields are legitimately absent depending on the state or outcome
251
+ of a record.
252
+
253
+ dataleaks train.csv --target target \
254
+ --conditional-time-column outcome_time \
255
+ --conditional-target-column target \
256
+ --conditional-present-when 1
257
+
258
+ This allows expected conditional absence to be distinguished from genuinely
259
+ invalid temporal data.
260
+
261
+ ๐Ÿšง Preprocessing Leakage
262
+
263
+ Leakage can happen before model training even begins.
264
+
265
+ โŒ Incorrect
266
+ Full Dataset
267
+ โ”‚
268
+ โ–ผ
269
+ Preprocessing.fit()
270
+ โ”‚
271
+ โ”œโ”€โ”€โ–บ Train
272
+ โ””โ”€โ”€โ–บ Test
273
+ โœ… Correct
274
+ Full Dataset
275
+ โ”‚
276
+ โ–ผ
277
+ Train / Test Split
278
+ โ”‚
279
+ โ”œโ”€โ”€โ–บ Train โ†’ fit()
280
+ โ”‚
281
+ โ””โ”€โ”€โ–บ Test โ†’ transform()
282
+
283
+ DataLeaks can analyze preprocessing workflow metadata.
284
+
285
+ metadata = {
286
+ "preprocessing": {
287
+ "fitted_on": "full_dataset",
288
+ "contaminated_by": ["test"],
289
+ }
290
+ }
291
+
292
+ report = DataLeaks(
293
+ df,
294
+ target="target",
295
+ metadata=metadata,
296
+ ).run()
297
+
298
+ This can identify:
299
+
300
+ Preprocessing fitted before the split
301
+ Training preprocessing contaminated by held-out data
302
+ ๐ŸŒ Cross-Dataset Leakage
303
+
304
+ DataLeaks can analyze overlap between datasets when reference data is supplied
305
+ through the supported dataset context.
306
+
307
+ This is useful for detecting shared entities or values that should remain
308
+ isolated between datasets.
309
+
310
+ ๐Ÿ“Š Risk Scoring
311
+
312
+ Every finding contains:
313
+
314
+ Severity
315
+ Confidence
316
+ Evidence
317
+ Explanation
318
+ Affected columns
319
+ Recommendation
320
+
321
+ The finding score is based on:
322
+
323
+ severity_weight ร— confidence
324
+ Severity weights
325
+ Severity Weight
326
+ ๐ŸŸข Low 0.25
327
+ ๐ŸŸก Medium 0.50
328
+ ๐ŸŸ  High 0.75
329
+ ๐Ÿ”ด Critical 1.00
330
+
331
+ The overall risk score is driven by the strongest finding.
332
+
333
+ This prevents many low-impact findings from hiding a single serious,
334
+ high-confidence leakage problem.
335
+
336
+ ๐Ÿ”Ž Structured Findings
337
+
338
+ DataLeaks returns structured finding objects instead of forcing users to parse
339
+ terminal output.
340
+
341
+ for finding in report.findings:
342
+ print("Detector:", finding.detector)
343
+ print("Category:", finding.category)
344
+ print("Severity:", finding.severity)
345
+ print("Confidence:", finding.confidence)
346
+ print("Columns:", finding.affected_columns)
347
+ print("Evidence:", finding.evidence)
348
+ print("Explanation:", finding.explanation)
349
+ print("Recommendation:", finding.recommendation)
350
+
351
+ This makes the output suitable for:
352
+
353
+ Python applications
354
+ Notebooks
355
+ CI/CD pipelines
356
+ Automated quality gates
357
+ Internal ML platforms
358
+ Custom dashboards
359
+ โš™๏ธ Detector Execution
360
+
361
+ DataLeaks tracks the execution state of detectors.
362
+
363
+ Supported states:
364
+
365
+ completed
366
+ failed
367
+ skipped
368
+
369
+ Inspect execution information through the report:
370
+
371
+ print(report.completed_detectors)
372
+ print(report.failed_detectors)
373
+ print(report.skipped_detectors)
374
+
375
+ Detector failures are therefore visible instead of being silently interpreted as
376
+ a clean analysis.
377
+
378
+ ๐Ÿงช Schema Validation
379
+
380
+ DataLeaks validates important dataset assumptions before analysis.
381
+
382
+ Validation includes:
383
+
384
+ Supported input type
385
+ Target column existence
386
+ Train/test schema compatibility
387
+ Missing columns
388
+ Dtype mismatches
389
+ Target presence
390
+
391
+ For example:
392
+
393
+ Error: Target column 'churn' does not exist in the dataset
394
+
395
+ Invalid input should fail clearly rather than producing misleading leakage
396
+ results.
397
+
398
+ ๐Ÿ“‹ JSON Reporting
399
+
400
+ For automation and CI/CD:
401
+
402
+ dataleaks train.csv --target target --output json
403
+
404
+ The JSON report contains structured information about:
405
+
406
+ Risk score
407
+ Risk level
408
+ Findings
409
+ Recommendations
410
+ Detector execution
411
+ Schema validation
412
+ Metadata
413
+ ๐Ÿ Python API
414
+
415
+ The primary API:
416
+
417
+ from dataleaks import DataLeaks
418
+
419
+ report = DataLeaks(
420
+ data,
421
+ target="target",
422
+ ).run()
423
+
424
+ Train / validation / test:
425
+
426
+ report = DataLeaks(
427
+ train,
428
+ target="target",
429
+ validation=validation,
430
+ test=test,
431
+ ).run()
432
+
433
+ Custom configuration:
434
+
435
+ from dataleaks import DataLeaks
436
+ from dataleaks.schemas import DataLeaksConfig
437
+
438
+ config = DataLeaksConfig(
439
+ enable_target_checks=True,
440
+ enable_split_checks=True,
441
+ enable_temporal_checks=True,
442
+ enable_preprocessing_checks=True,
443
+ enable_feature_checks=True,
444
+ enable_cross_dataset_checks=True,
445
+ )
446
+
447
+ report = DataLeaks(
448
+ df,
449
+ target="target",
450
+ config=config,
451
+ ).run()
452
+ ๐Ÿงฉ Architecture
453
+
454
+ DataLeaks follows an extensible detector architecture:
455
+
456
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
457
+ โ”‚ Input โ”‚
458
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
459
+ โ”‚
460
+ โ–ผ
461
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
462
+ โ”‚DatasetContext โ”‚
463
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
464
+ โ”‚
465
+ โ–ผ
466
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
467
+ โ”‚DetectorRegistryโ”‚
468
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
469
+ โ”‚
470
+ โ–ผ
471
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
472
+ โ”‚ DetectorRunnerโ”‚
473
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
474
+ โ”‚
475
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
476
+ โ–ผ โ–ผ โ–ผ โ–ผ โ–ผ
477
+ Target Split Temporal Feature Preprocessing
478
+ Checks Checks Checks Checks Checks
479
+ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚
480
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
481
+ โ”‚
482
+ โ–ผ
483
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
484
+ โ”‚ Findings โ”‚
485
+ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
486
+ โ”‚
487
+ โ–ผ
488
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
489
+ โ”‚Aggregationโ”‚
490
+ โ””โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜
491
+ โ”‚
492
+ โ–ผ
493
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
494
+ โ”‚ Scoring โ”‚
495
+ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜
496
+ โ”‚
497
+ โ–ผ
498
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
499
+ โ”‚ Recommendationsโ”‚
500
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
501
+ โ”‚
502
+ โ–ผ
503
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
504
+ โ”‚ LeakageReport โ”‚
505
+ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
506
+ โ”‚
507
+ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
508
+ โ–ผ โ–ผ
509
+ Console JSON
510
+
511
+ Detectors implement a common interface and are managed through a detector
512
+ registry, allowing the system to grow without redesigning the complete
513
+ reporting and scoring pipeline.
514
+
515
+ โš™๏ธ Configuration
516
+
517
+ Detector categories and analysis thresholds can be configured:
518
+
519
+ from dataleaks.schemas import DataLeaksConfig
520
+
521
+ config = DataLeaksConfig(
522
+ duplicate_threshold=0.0,
523
+ near_duplicate_threshold=0.95,
524
+ confidence_threshold=0.5,
525
+ )
526
+
527
+ Configuration values are validated to remain within supported ranges.
528
+
529
+ ๐Ÿงช Example Detection
530
+
531
+ Consider a dataset containing:
532
+
533
+ customer_id
534
+ leaky_id
535
+ tenure_months
536
+ monthly_charges
537
+ target_leak_direct
538
+ post_outcome_refund
539
+ target
540
+
541
+ DataLeaks can produce findings such as:
542
+
543
+ target_statistical
544
+ HIGH
545
+ Strong feature-target relationship detected
546
+
547
+ split_overlap
548
+ HIGH
549
+ Entity values overlap between train and test
550
+
551
+ feature_suspicious
552
+ HIGH
553
+ Post-outcome semantic signal detected
554
+
555
+ feature_identifier
556
+ MEDIUM
557
+ Identifier-like feature detected
558
+
559
+ The findings are then aggregated into a single leakage risk assessment.
560
+
561
+ ๐Ÿง  Design Principles
562
+ Execution-first
563
+
564
+ Analyze actual dataset and workflow evidence rather than relying exclusively on
565
+ static assumptions.
566
+
567
+ Conservative detection
568
+
569
+ A suspicious signal is not automatically treated as proof of leakage.
570
+
571
+ Explainability
572
+
573
+ Every finding should answer:
574
+
575
+ What happened? Why does it matter? What should I do?
576
+
577
+ Structured output
578
+
579
+ Findings are machine-readable objects that can be consumed by other systems.
580
+
581
+ Extensibility
582
+
583
+ New detectors can be added without redesigning the entire architecture.
584
+
585
+ Production awareness
586
+
587
+ Leakage can originate from datasets, splits, features, timestamps,
588
+ preprocessing, identifiers, and workflow metadata.
589
+
590
+ โš ๏ธ Current Scope & Limitations
591
+
592
+ DataLeaks 0.1.0 focuses on dataset- and workflow-level leakage detection.
593
+
594
+ Some workflow-level checks require explicit metadata because operations performed
595
+ outside the dataset cannot always be inferred reliably.
596
+
597
+ For example, preprocessing contamination requires information about how the
598
+ preprocessing workflow was fitted.
599
+
600
+ Temporal metadata is also explicitly supplied by the user rather than guessed
601
+ automatically.
602
+
603
+ This is intentional.
604
+
605
+ DataLeaks prefers explicit, explainable evidence over unsupported assumptions.
606
+
607
+ ๐Ÿงช Testing
608
+
609
+ DataLeaks is heavily test-driven.
610
+
611
+ <div align="center">
612
+ โœ… 521 Tests Passed
613
+ </div>
614
+
615
+ The test suite includes:
616
+
617
+ Unit tests
618
+ Integration tests
619
+ Regression tests
620
+ Adversarial datasets
621
+ Target leakage cases
622
+ Split leakage cases
623
+ Temporal edge cases
624
+ Timestamp parsing
625
+ Preprocessing contamination
626
+ Schema validation
627
+ Detector execution
628
+ Scoring
629
+ Reporting
630
+ CLI behavior
631
+ Packaging
632
+
633
+ Run the complete suite:
634
+
635
+ pytest -q -W error
636
+ ๐Ÿ“ฆ Building From Source
637
+
638
+ Build the distributions:
639
+
640
+ python -m build
641
+
642
+ This produces:
643
+
644
+ dist/
645
+ โ”œโ”€โ”€ dataleaks-0.1.0-py3-none-any.whl
646
+ โ””โ”€โ”€ dataleaks-0.1.0.tar.gz
647
+
648
+ Validate them before publishing:
649
+
650
+ python -m twine check --strict dist/*
651
+ ๐Ÿ›ฃ๏ธ Roadmap
652
+
653
+ DataLeaks 0.1.0 establishes the core leakage-detection engine.
654
+
655
+ Future releases will expand workflow-level capabilities:
656
+
657
+ ๐Ÿ”Œ scikit-learn pipeline adapters
658
+ ๐Ÿ”Œ Additional ML framework adapters
659
+ ๐Ÿ” Richer workflow introspection
660
+ โฑ๏ธ Expanded temporal analysis
661
+ ๐Ÿงฌ Additional entity-resolution strategies
662
+ ๐ŸŒ Broader cross-dataset analysis
663
+ ๐Ÿค– CI/CD integrations
664
+ ๐Ÿ“Š Additional reporting formats
665
+ ๐Ÿ”— ML workflow integrations
666
+
667
+ The planned adapter architecture will allow DataLeaks to inspect complete ML
668
+ workflows while preserving the same detector, scoring, and reporting system.
669
+
670
+ ๐Ÿค Contributing
671
+
672
+ Contributions, detector ideas, bug reports, and adversarial regression cases are
673
+ welcome.
674
+
675
+ When adding a detector, include:
676
+
677
+ Detector implementation
678
+ Unit tests
679
+ Regression tests where appropriate
680
+ Adversarial / false-positive tests where appropriate
681
+ Clear evidence
682
+ Explanation
683
+ Actionable recommendation
684
+
685
+ Before submitting changes:
686
+
687
+ pytest -q -W error
688
+ ๐Ÿ“„ License
689
+
690
+ DataLeaks is released under the MIT License.
691
+
692
+ See LICENSE.
693
+
694
+ <div align="center">
695
+ ๐Ÿ” DataLeaks
696
+ Find leakage before it finds your model.
697
+
698
+ Reliable leakage detection for machine learning workflows.
699
+
700
+ </div> ```