API
anonymization_manager.config.AnonymizationConfig
Bases: BaseModel
Configuration object for the anonymization workflow.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
str
|
Path to the input dataset. Supported formats include CSV, Excel, JSON, and SQLite (.db) files. |
identifiers |
list[str]
|
List of direct identifiers (e.g., name, SSN, phone number). |
quasi_identifiers |
list[str]
|
List of quasi-identifying attributes requiring generalization (e.g., age, zipcode, occupation). |
sensitive_attributes |
list[str]
|
Attributes considered sensitive (e.g., disease, salary) If not empty, either l-diversity or t-closeness must be specified. |
insensitive_attributes |
list[str]
|
Attributes that are neither identifiers nor sensitive and are carried through unchanged. |
hierarchies |
dict[str, str]
|
Mapping from quasi-identifiers to CSV hierarchy files. |
k |
int
|
k value for k-anonymity. Must be positive integer. |
l |
int
|
l value for l-diversity. Must be positive integer. |
t |
float
|
t value for t-closeness. Must be a float in [0,1]. |
suppression_limit |
float
|
Maximum percentage of suppressed rows allowed (0-100%). Must be a float in [0,1]. |
backend |
str
|
Anonymization backend to use, either 'arx' or 'anjana'. Defaults to 'arx'. |
quality_metric |
dict[Any]
|
A dictionary holding the information related to the quality metric. For more information, check the documentation. |
attribute_weights |
dict[str, float]
|
A set assigning weight "importance" to each attribute. |
Source code in src/anonymization_manager/config.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |
from_json(json_path)
classmethod
Constructs an AnonymizationConfig from a JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_path
|
str
|
Path to the JSON configuration file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AnonymizationConfig |
The constructed and validated configuration object. |
Source code in src/anonymization_manager/config.py
anonymization_manager.core.AnonymizationManager
Entry point for the anonymization workflow.
Directs execution to the appropriate backend adapter, wraps the result, and returns it to the caller.
Source code in src/anonymization_manager/core.py
anonymize(config)
Anonymizes the dataset using the anonymization config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
AnonymizationConfig
|
The configuration the anonymization manager must respect. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AnonymizedData |
AnonymizedData
|
A unified wrapper around the backend-specific result object. |
Raises:
| Type | Description |
|---|---|
Exception
|
If the underlying anonymization engine fails. |
Source code in src/anonymization_manager/core.py
anonymization_manager.adapters.arx.ARXResult
Wrapper for the ARX Java Result object.
Provides Pythonic access to anonymization results, equivalence class statistics, and various quality metrics.
Source code in src/anonymization_manager/adapters/arx/arx.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
__init__(java_arx_result)
Initializes the ARXResult wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
java_arx_result
|
ARXResult
|
The Java Arx result object. |
required |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_ambiguity_metric()
Returns the ambiguity metric.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Ambiguity metric value. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_anonymization_time()
Returns the wall-clock time taken for anonymization.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Time in milliseconds. |
get_anonymized_data_as_dataframe()
Returns the anonymized dataset as a pandas DataFrame.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.Dataframe: Anonymized data. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_attribute_level_squared_error_metric(attribute)
Returns the attribute level squared metric for a specific attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
str
|
The attribute name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Attribute-level squared error value. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_average_class_size_metric()
Returns the average class size metric.
Note
This metric is different from the average equivalence class size.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Average class size metric value. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_average_equivalence_class_size()
Returns the average size of equivalence classes.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Average equivalence class size. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_discernability_metric()
Returns the discernability metric, a measure of information loss.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
discernability metric value. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_generalization_intensity_metric(attribute)
Returns the generalization intensity metric for a specific attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
str
|
The attribute name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Generalization intensity value. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_granularity_metric(attribute)
Returns the granularity metric for a specific attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
str
|
The attribute name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Granularity metric value. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_max_equivalence_class_size()
Returns the maximum equivalence class size.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Maximum equivalence class size. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_min_equivalence_class_size()
Returns the minimum equivalence class size.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Minimum equivalence class size. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_non_uniform_entropy_metric(attribute)
Returns the non-uniform entropy metric for a specific attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
attribute
|
str
|
The attribute name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Non-uniform entropy value. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_number_of_equivalence_classes()
Returns the number of equivalence classes.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Number of equivalence classes. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_number_of_suppressed_records()
Returns the number of suppressed (removed) records.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Number of suppressed records. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_raw_data_as_dataframe()
Returns the original (raw) dataset as a pandas DataFrame.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Original data. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_record_level_squared_error_metric()
Returns the record-level squared error metric.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Record-level squared error value. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_ssesst_metric()
Returns the SSESST metric value.
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
SSESST metric value. |
Source code in src/anonymization_manager/adapters/arx/arx.py
get_transformations()
Gets the generalization levels applied to quasi-identifiers.
Returns:
| Type | Description |
|---|---|
dict[str, int]
|
dict[str, int]: Mapping of quasi-identifier names to their generalization level. |
Source code in src/anonymization_manager/adapters/arx/arx.py
store_as_csv(output_path)
Stores the anonymized dataset as CSV file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_path
|
str
|
File path to save the CSV. |
required |
Source code in src/anonymization_manager/adapters/arx/arx.py
anonymization_manager.adapters.anjana.AnjanaResult
Wrapper class for Anjana's anonymized results.
Source code in src/anonymization_manager/adapters/anjana/anjana.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
get_ambiguity_metric()
get_anonymization_time()
get_anonymized_data_as_dataframe()
get_attribute_level_squared_error_metric(attribute)
Returns the attribute level squared metric for the anonymized dataset.
get_average_class_size_metric()
Returns the average class metric, not to be confused with the other similarly named method.
get_average_equivalence_class_size()
Returns the average equivalence class size.
get_discernability_metric()
Returns the discernibility metric for the anonymized dataset.
Source code in src/anonymization_manager/adapters/anjana/anjana.py
get_generalization_intensity_metric(attribute)
Returns the generalization intensity metric for the specific attribute in the anonymized dataset.
get_granularity_metric(attribute)
get_max_equivalence_class_size()
Returns the maximum size of an equivalence class present in the anonymized dataset.
get_min_equivalence_class_size()
Returns the minimum size of an equivalence class present in the anonymized dataset.
get_non_uniform_entropy_metric(attribute)
Returns the non uniform entropy metric for the specific attribute in the anonymized dataset.
get_number_of_equivalence_classes()
Returns the number of equivalence classes present in the anonymized dataset.
get_number_of_suppressed_records()
Returns the number of suppressed records, i.e. removed from the dataset.
Source code in src/anonymization_manager/adapters/anjana/anjana.py
get_raw_data_as_dataframe()
get_record_level_squared_error_metric()
get_ssesst_metric()
get_transformations()
Returns the transformations applied to each quasi-identifier.