mic-dp 0.1__py3-none-any.whl

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.

Potentially problematic release.


This version of mic-dp might be problematic. Click here for more details.

@@ -0,0 +1,5 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy...
@@ -0,0 +1,160 @@
1
+ Metadata-Version: 2.1
2
+ Name: mic_dp
3
+ Version: 0.1
4
+ Summary: A Python package for maximum information coefficient differential privacy
5
+ Home-page: https://github.com/uwtintres/mic-dp
6
+ Author: Wenjun Yang, Eyhab Al-masri, Olivera Kotevska
7
+ Author-email: wy927@uw.edu, ealmasri@uw.edu, kotevskao@ornl.gov
8
+ Keywords: differential-privacy mic machine-learning privacy-preserving feature-selection
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
13
+ Classifier: Topic :: Security :: Cryptography
14
+ Classifier: Development Status :: 4 - Beta
15
+ Requires-Python: >=3.7
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: diffprivlib
19
+ Requires-Dist: scikit-learn
20
+ Requires-Dist: pandas
21
+ Requires-Dist: numpy
22
+ Requires-Dist: matplotlib
23
+ Requires-Dist: seaborn
24
+ Requires-Dist: scipy
25
+ Requires-Dist: lifelines
26
+ Requires-Dist: statsmodels
27
+
28
+ # MIC_DP: Maximum Information Coefficient Differential Privacy
29
+
30
+ `mic_dp` is a Python package that enables differentially private data transformation guided by the *Maximum Information Coefficient* (MIC), with application to both supervised and unsupervised learning tasks. Traditional differential privacy (DP) mechanisms often degrade utility uniformly across features. In contrast, `mic_dp` uses MIC to scale the noise injection, preserving more utility in informative features.
31
+
32
+ ## Summary
33
+
34
+ This package includes functions for:
35
+ - Calculating MIC, Pearson, and Mahalanobis-based feature relevance
36
+ - Feature selection based on scaled importance
37
+ - Applying Gaussian or Laplace DP mechanisms using custom noise scaling
38
+ - Evaluating MAE, clustering scores, and plotting results
39
+
40
+ Our experiments show that MIC-guided DP mechanisms consistently outperform Pearson, Mahalanobis, and baseline DP in terms of feature and prediction accuracy under privacy constraints. In unsupervised settings, MIC-DP preserves cluster structures better, as shown by silhouette score, ARI, and V-measure.
41
+
42
+ ## Installation
43
+
44
+ You can install the package directly from PyPI:
45
+
46
+ ```bash
47
+ pip install micdp
48
+ ```
49
+
50
+ Or install from source:
51
+
52
+ ```bash
53
+ git clone https://github.com/merlery/mic_dp.git
54
+ cd mic_dp
55
+ pip install -e .
56
+ ```
57
+
58
+ ## Quick Start
59
+
60
+ Here's a simple example of how to use `mic_dp` for supervised learning:
61
+
62
+ ```python
63
+ import pandas as pd
64
+ import numpy as np
65
+ from sklearn.preprocessing import MinMaxScaler
66
+ from mic_dp.core import (
67
+ noise_scaling_MIC,
68
+ calculate_sensitivity,
69
+ correlated_dp_gaussian,
70
+ mean_absolute_error
71
+ )
72
+
73
+ # Load and preprocess your data
74
+ df = pd.read_csv('your_dataset.csv')
75
+ df.dropna(inplace=True)
76
+ X = df.select_dtypes(include=['number'])
77
+ X_norm = pd.DataFrame(MinMaxScaler().fit_transform(X), columns=X.columns)
78
+ y = df['target_column'] # Your target variable
79
+
80
+ # Calculate MIC-based noise scaling factors
81
+ noise_factors = noise_scaling_MIC(y, X_norm, amplification_factor=5)
82
+
83
+ # Calculate sensitivity for each feature
84
+ sensitivity = calculate_sensitivity(X_norm)
85
+
86
+ # Apply differential privacy with MIC-guided noise scaling
87
+ private_X = correlated_dp_gaussian(
88
+ X_norm.copy(),
89
+ noise_factors,
90
+ sensitivity,
91
+ epsilon=0.5, # Privacy budget
92
+ delta=1e-5 # Privacy relaxation parameter
93
+ )
94
+
95
+ # Evaluate the utility loss
96
+ mae = mean_absolute_error(X_norm, private_X)
97
+ print(f"Mean Absolute Error: {mae:.4f}")
98
+ ```
99
+
100
+ ## Detailed Example
101
+
102
+ For a more comprehensive example, see the [supervised_experiment.py](examples/supervised_experiment.py) script, which demonstrates:
103
+
104
+ 1. Loading and preprocessing the Adult Census Income dataset
105
+ 2. Calculating feature relevance using MIC, Pearson, and Mahalanobis methods
106
+ 3. Applying differential privacy with different noise scaling strategies
107
+ 4. Evaluating and comparing the utility of each approach
108
+ 5. Visualizing the results
109
+
110
+ To run the example:
111
+
112
+ ```bash
113
+ python examples/supervised_experiment.py
114
+ ```
115
+
116
+ ## Experimental Results
117
+
118
+ MIC-guided noise scaling consistently outperforms conventional approaches in preserving prediction accuracy and clustering structure under differential privacy constraints.
119
+
120
+ ![Feature MAE comparison for MIC-DP vs. state-of-art approaches](MAE.png)
121
+ ![Prediction MAE comparison for MIC-DP vs. state-of-art approaches](MAE_pred.png)
122
+
123
+ ## API Reference
124
+
125
+ ### Core Functions
126
+
127
+ - `noise_scaling_MIC(target, features, factor)`: Calculate noise scaling factors based on Maximum Information Coefficient
128
+ - `noise_scaling_pearson(target, features, factor)`: Calculate noise scaling factors based on Pearson correlation
129
+ - `noise_scaling_mahalanobis_distances(target, features, factor)`: Calculate noise scaling factors based on Mahalanobis distances
130
+ - `calculate_sensitivity(features)`: Calculate sensitivity for each feature based on its range
131
+ - `correlated_dp_gaussian(X, noise_factors, sensitivity, epsilon, delta)`: Apply Gaussian differential privacy with custom noise scaling
132
+ - `correlated_dp_laplace(X, noise_factors, sensitivity, epsilon, delta)`: Apply Laplace differential privacy with custom noise scaling
133
+ - `feature_selection(percentage, X, noise_scaling_factor)`: Select features based on their noise scaling factors
134
+ - `mean_absolute_error(y_true, y_pred)`: Calculate mean absolute error between true and predicted values
135
+ - `cluster_and_evaluate(df, name, n_clusters)`: Perform clustering and evaluate the results
136
+ - `calculate_ari(labels1, labels2)`: Calculate Adjusted Rand Index between two cluster labelings
137
+ - `calculate_v_measure(labels1, labels2)`: Calculate V-measure between two cluster labelings
138
+
139
+ ## Citation
140
+
141
+ If you use this package in your research, please cite:
142
+
143
+ ```
144
+ @article{yang2025micdp,
145
+ title={mic\_dp: A Python package for maximum information coefficient differential privacy},
146
+ author={Yang, Wenjun and Al-masri, Eyhab and Kotevska, Olivera},
147
+ journal={Journal of Open Source Software},
148
+ year={2025}
149
+ }
150
+ ```
151
+
152
+ ## License
153
+
154
+ This project is licensed under the MIT License - see the LICENSE file for details.
155
+
156
+ ## Acknowledgements
157
+
158
+ We acknowledge the creators of the ACI and HED datasets for making their data publicly available.
159
+
160
+ ## References
@@ -0,0 +1,5 @@
1
+ mic_dp-0.1.dist-info/LICENSE,sha256=fU6gYh2_CWA-FiM2tHIUUzp-Z5yc-Pz11k1vVDL0CSY,113
2
+ mic_dp-0.1.dist-info/METADATA,sha256=1bYzU5WxwyA-KDGtlrdPQl17OJ8JLpCt0RVJSojWjpo,6293
3
+ mic_dp-0.1.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
4
+ mic_dp-0.1.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
+ mic_dp-0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (72.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+