Skip to content

Commit

Permalink
modify readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
glassonion1 committed Oct 16, 2021
1 parent 7135e81 commit 9ac8f70
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 7 deletions.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
# anonypy
# AnonyPy
Anonymization library for python

## Install
```
$ pip install anonypy
```

## Usage
```python
import anonypy
import pandas as pd

def main():
path = 'data/adult.test.txt'
df = pd.read_csv(path, sep=', ', names=names, engine='python')

for name in categorical:
df[name] = df[name].astype('category')

feature_columns = ['age', 'education-num']
m = anonypy.Mondrian(df, feature_columns)
partitions = m.partition(anonypy.is_k_anonymous)
print(partitions)
```
1 change: 1 addition & 0 deletions anonypy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from anonypy.anonypy import *
from .mondrian import Mondrian
22 changes: 20 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
from setuptools import setup, find_packages
from os import path

here = path.abspath(path.dirname(__file__))

with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()

setup(
name='anonypy',
version='0.1',
packages=find_packages()
version='0.0.1',
packages=find_packages(),
author='glassonion1',
author_email='glassonion999@gmail.com',
description='Anonymization library for python',
long_description=long_description,
long_description_content_type='text/markdown',
keywords='k-anonymity l-diversity t-closeness',
classifiers=[
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
)
7 changes: 3 additions & 4 deletions tests/anonypy_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import anonypy
from anonypy import util
from anonypy import mondrian
import pandas as pd

names = (
Expand Down Expand Up @@ -41,7 +40,7 @@ def test_build_anonymized_dataset():
df[name] = df[name].astype('category')

feature_columns = ['age', 'education-num']
m = mondrian.Mondrian(df, feature_columns)
m = anonypy.Mondrian(df, feature_columns)
finished_partitions = m.partition(anonypy.is_k_anonymous)

print(len(finished_partitions))
Expand All @@ -66,13 +65,13 @@ def test_get_spans():
df[name] = df[name].astype('category')

feature_columns = ['age', 'education-num']
m = mondrian.Mondrian(df, feature_columns)
m = anonypy.Mondrian(df, feature_columns)
spans = m._get_spans(df.index)

assert {'age': 73, 'education-num': 15} == spans

feature_columns = ['sex', 'income', 'native-country', 'race']
m = mondrian.Mondrian(df, feature_columns)
m = anonypy.Mondrian(df, feature_columns)
spans = m._get_spans(df.index)

assert {'income': 2, 'sex': 2, 'native-country': 41, 'race': 5} == spans
Expand Down

0 comments on commit 9ac8f70

Please sign in to comment.