Package: antigranular
Privacy Unleashed: Working with AntigranularAntigranular is a community-led, open-source platform that combines confidential computing with differential privacy. This integration fosters a secure environment to handle and fully utilize unseen data.Connect to AntigranularYou can activate Antigranular using the magic command%%ag. Any code that follows%%agwill run on our remote server. This server operates under restricted conditions, allowing only methods that guarantee differential privacy.Install the Antigranular package usingpip:!pipinstallantigranularImport theAntigranularlibrary:importantigranularasagTo connect to the AG Enclave Server, use your client credentials and either a dataset or competition ID:ag_client=ag.login(user_id="<user_id>",user_secret="<user_secret>",competition="<competition_name>")orag_client=ag.login(user_id="<user_id>",user_secret="<user_secret>",dataset="<dataset_name>")A succesful login will register the cell magic%%ag.Loading Private DatasetsPrivate datasets can be loaded asPrivateDataFramesandPrivateSeriesusing theag_utilslibrary.ag_utilsis a package locally installed on the remote server, which eliminates the need to install anything other than the antigranular package.Theload_dataset()method allows for obtaining a dictionary of private objects. The structure of the response dictionary, along with the dataset path and private object names, will be specified during the competition.%%agfromop_pandasimportPrivateDataFrame,PrivateSeriesfromag_utilsimportload_dataset"""Sample response structure{train_x : priv_train_x,train_y : priv_train_y,test_x : priv_test_x}"""# Obtaining the dictionary containing private objectsresponse=load_dataset("<path_to_dataset>")# Unpacking the response dictionarytrain_x=response["train_x"]train_y=response["train_y"]test_x=response["test_x"]Exporting ObjectsSince the code following%%agruns in a highly restricted environment, it's necessary to export differentially private objects to the local environment for further analysis. Theexportmethod inag_utilsallows data objects to be exported.API info:export(obj, variable_name:str)This command exports the remote object to the local environment and assigns it to the specified variable name. Note thatPrivateSeriesandPrivateDataFrameobjects cannot be exported and will raise an error if you attempt to do so.%%agfromag_utilsimportexporttrain_info=train_x.describe(eps=1)export(train_info,'variable_name')Once exported, you can perform any kind of data analysis on the differentially private object.# Local code blockprint(variable_name)--------------------------------------AgeSalarycount99987.00000099987.000000mean38.435953120009.334336std12.16737946255.486093min18.25744840048.25903725%27.18518980057.63996050%38.210860120380.29121675%49.147724159835.637091max59.282932199920.664706Libraries Supportedpandas: An adaptable data manipulation library offering efficient data structures and tools for data analysis and manipulation.op_pandas: A wrapped library specifically designed for differentially private data manipulation within the Pandas framework. It enhances privacy-preserving techniques and enables privacy-aware data processing.op_diffprivlib: A differentially private library that provides various privacy-preserving algorithms and mechanisms for machine learning and data analysis tasks.op_smartnoise: A library focused on privacy-preserving analysis using the SmartNoise framework. It provides tools for differential privacy and secure computation.op_opendp: A library that offers differentially private data analysis and algorithms based on the OpenDP project. It provides privacy-preserving methods and tools for statistical analysis.