trasgoDP logo

Description

trasgoDP implements mechanisms for ε-differential privacy (numerical and categorical data), (ε, δ)-differential privacy (numerical data) and metric-privacy (location-based data). The mechanisms are implemented for use in a local approach, adding noise directly to the raw data.

  • Numerical records: Laplace and Gaussian mechanisms. The implementation includes a final clipping applied on the data when using DP.
  • Categorical records: Exponential mechanism and Randomized Response (both for binary attributes and the k-ary version).
  • Location-based records: Geo-indistinguishability mechanism for metric-privacy.

Example 1: Local DP on general attributes

Apply DP to the adult dataset with the Laplace mechanism for age and the Exponential mechanism for workclass:

import pandas as pd
from trasgodp.numerical import dp_clip_laplace
from trasgodp.categorical import dp_exponential

# Read and process the data
data = pd.read_csv("examples/adult.csv")
data.columns = data.columns.str.strip()
cols = [
    "workclass",
    "education",
    "marital-status",
    "occupation",
    "sex",
    "native-country",
]
for col in cols:
    data[col] = data[col].str.strip()

# Apply DP for the attribute age:
column_num = "age"
epsilon1 = 10
df = dp_clip_laplace(data, column_num, epsilon1, new_column=True)

# Apply DP for the attribute workclass:
column_cat = "workclass"
epsilon2 = 5
df = dp_exponential(data, column_cat, epsilon2, new_column=True)

Example 2: Metric privacy on location data

Apply metric privacy to the trip_data.csv dataset from the examples folder and plot the interactive map:

import pandas as pd
from trasgodp.geoindis import metric_privacy, plot_metric_dp_map

# Read the data
data = pd.read_csv("./examples/trip_data.csv")
column_lat = "pickup_latitude"
column_lon = "pickup_longitude"

# Apply metric privacy creating new columns for lat and lon:
epsilon = 1.e-2
data_priv = metric_privacy(data, column_lat, column_lon, epsilon, new_cols=True)

# Plot and save the map:
plot_metric_dp_map(data_priv[:50], column_lat, column_lon, save_file="example_map_trip.html")

These data are a sample of NYC taxi trip records containing pickup and drop-off coordinates, timestamps, and other trip metadata, such as distance, duration, and passenger information. Only the first 50 examples are plotted to make the map easier to visualize.

Interactive map

Resulting interactive map (embedded from the example page):

Open map in new tab

Access the interactive application

The trasgoDP dashboard is available at trasgodp.cloud.eosc-siesta.eu. For testing purposes, the interface can be used when the input files are smaller than 10 MB. For real-world use with data larger than 10 MB, please contact the team for access and login.

Open dashboard

Dashboard preview

trasgoDP dashboard preview