trasgodp.geoindis package¶
Module contents¶
Metric privacy mechanisms for location data.
- trasgodp.geoindis.metric_privacy(df, column_lat, column_lon, epsilon, new_cols=False, earth_radius_m=6371000, seed=42)¶
Apply geo-indistinguishability to the columns of a DataFrame with lat, lon pairs.
- Parameters:
df (pd.DataFrame) – DataFrame containing the column to be disturbed.
column_lat (str) – name of the column containing latitudes.
column_lon (str) – name of the column containing longitudes.
epsilon (float) – privacy budget.
new_cols (bool) – if True, add new columns with the perturbed values. Otherwise, overwrite the original columns.
earth_radius_m (float) – radius of the Earth in meters.
seed (int) – random seed for reproducibility.
- Returns:
DataFrame with the perturbed location data (including radius).
- Return type:
pd.DataFrame
- trasgodp.geoindis.plot_metric_dp_map(df_dp, column_lat, column_lon, save_file='metric_dp_map.html')¶
Plot (and save) a map with the original and perturbed locations, and the radius.
- Parameters:
df_dp (pd.DataFrame) – DataFrame containing both the original and perturbed data. This DataFrame must be generated including new_cols=True in the metric_privacy function.
column_lon (str) – name of the column containing longitudes.
column_lat (str) – name of the column containing latitudes.
save_file (str) – name of the file where the map will be saved.
- Returns:
map.
- Return type:
folium.Map