Skip to main content

MIC_DP: Maximum Information Coefficient Differential Privacy

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.

Summary

This package includes functions for:

  • Calculating MIC, Pearson, and Mahalanobis-based feature relevance
  • Feature selection based on scaled importance
  • Applying Gaussian or Laplace DP mechanisms using custom noise scaling
  • Evaluating MAE, clustering scores, and plotting results

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.

Installation

You can install the package directly from PyPI:

pip install micdp

Or install from source:

git clone https://github.com/merlery/mic_dp.git
cd mic_dp
pip install -e .

Quick Start

Here's a simple example of how to use mic_dp for supervised learning:

import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler
from core import (
    noise_scaling_MIC,
    calculate_sensitivity,
    correlated_dp_gaussian,
    mean_absolute_error
)

# Load and preprocess your data
df = pd.read_csv('your_dataset.csv')
df.dropna(inplace=True)
X = df.select_dtypes(include=['number'])
X_norm = pd.DataFrame(MinMaxScaler().fit_transform(X), columns=X.columns)
y = df['target_column']  # Your target variable

# Calculate MIC-based noise scaling factors
noise_factors = noise_scaling_MIC(y, X_norm, amplification_factor=5)

# Calculate sensitivity for each feature
sensitivity = calculate_sensitivity(X_norm)

# Apply differential privacy with MIC-guided noise scaling
private_X = correlated_dp_gaussian(
    X_norm.copy(),
    noise_factors,
    sensitivity,
    epsilon=0.5,  # Privacy budget
    delta=1e-5  # Privacy relaxation parameter
)

# Evaluate the utility loss
mae = mean_absolute_error(X_norm, private_X)
print(f"Mean Absolute Error: {mae:.4f}")

Detailed Example

For a more comprehensive example, see the supervised_experiment.py script, which demonstrates:

  1. Loading and preprocessing the Adult Census Income dataset
  2. Calculating feature relevance using MIC, Pearson, and Mahalanobis methods
  3. Applying differential privacy with different noise scaling strategies
  4. Evaluating and comparing the utility of each approach
  5. Visualizing the results

To run the example:

python examples/supervised_experiment.py

Experimental Results

MIC-guided noise scaling consistently outperforms conventional approaches in preserving prediction accuracy and clustering structure under differential privacy constraints.

Feature MAE comparison for MIC-DP vs. state-of-art approaches Prediction MAE comparison for MIC-DP vs. state-of-art approaches

API Reference

Core Functions

  • noise_scaling_MIC(target, features, factor): Calculate noise scaling factors based on Maximum Information Coefficient
  • noise_scaling_pearson(target, features, factor): Calculate noise scaling factors based on Pearson correlation
  • noise_scaling_mahalanobis_distances(target, features, factor): Calculate noise scaling factors based on Mahalanobis distances
  • calculate_sensitivity(features): Calculate sensitivity for each feature based on its range
  • correlated_dp_gaussian(X, noise_factors, sensitivity, epsilon, delta): Apply Gaussian differential privacy with custom noise scaling
  • correlated_dp_laplace(X, noise_factors, sensitivity, epsilon, delta): Apply Laplace differential privacy with custom noise scaling
  • feature_selection(percentage, X, noise_scaling_factor): Select features based on their noise scaling factors
  • mean_absolute_error(y_true, y_pred): Calculate mean absolute error between true and predicted values
  • cluster_and_evaluate(df, name, n_clusters): Perform clustering and evaluate the results
  • calculate_ari(labels1, labels2): Calculate Adjusted Rand Index between two cluster labelings
  • calculate_v_measure(labels1, labels2): Calculate V-measure between two cluster labelings

Citation

If you use this package in your research, please cite:

@article{yang2025micdp,
  title={mic\_dp: A Python package for maximum information coefficient differential privacy},
  author={Yang, Wenjun and Al-masri, Eyhab and Kotevska, Olivera},
  journal={Journal of Open Source Software},
  year={2025}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

We acknowledge the creators of the ACI and HED datasets for making their data publicly available.

References

Metadata

Release files for mic-dp 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mic-dp 0.3
File Size Uploaded
mic_dp-0.3.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mic-dp 0.3
File Interpreter ABI Platform
mic_dp-0.3-py3-none-any.whl Python 3 none any Details

Total release size: 7.6 kB

Release files / mic_dp-0.3.tar.gz

Download URL mic_dp-0.3.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
931792cee3b2044038e965bc62fdca2d9d9d5d01cd079fbc6134c34f9a3adb5d
BLAKE2b-256 checksum
How to use checksums
0daf508e68d5a99d042b743364224b662836ab87e6c2bbf4a5e3a45e0ae53347
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release files / mic_dp-0.3-py3-none-any.whl

Download URL mic_dp-0.3-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6221590fb869d7ea4f97aada8218f9b0c5cfa3dbc3a01e733d011fe517ca51e3
BLAKE2b-256 checksum
How to use checksums
4f02c82cde376b951058b08104c7c0f21e46a5268bdbbfa01c857113177e37b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.20

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page