synthetic_aia_mia.aia package — src documentation

# synthetic_aia_mia.aia package

## Submodules

## synthetic_aia_mia.aia.soft module

Define structures to manage and interface a fully connected neural network for attribute inference attack using soft labels.

class synthetic_aia_mia.aia.soft.AiaDataset(data)

  Bases: `Dataset`

  Pytorch dataset to handle aia with soft labels.

class synthetic_aia_mia.aia.soft.AiaNN

  Bases: `object`

  Wrapper arround pytorch neural network. Interfare for hyper parameter optimisation using raytune.

  fit(dadata, attrib)

    Train and tune hyper parameters.

    Parameters:

      - data – Dataset the will be split for training and hyper parameter tuning. Dataset must contain columns called “soft0” and “soft1” used as features.

      - attrib (str) – Sensitive attribute to attack. A column of dadata.

  predict(dadata)

    Use a trained TabularNN to predict label of dataset.

    Parameters:

      dadata (fetch_data.Dataset) – Dataset to evaluate.

    Returns:

      Input dataset completed with hard labels, soft labels and loss.

    Return type:

      fetch_data.Dataset

class synthetic_aia_mia.aia.soft.TabularNN(input_size, l1, l2, output_size)

  Bases: `Module`

  Pytorch neural network for adult.

  forward(x)

    Forward pass in the neural network.

    Parameters:

      x (torch.tensor) – Data points.

    Returns:

      Neural network function applied to x.

    Return type:

      torch.tensor

## Module contents

Attribute inference attack.

class synthetic_aia_mia.aia.Aia

  Bases: `object`

  High level interface for attribute inference attack. Execute soft and hard attack.

  fit(data)

    Fit aia for hard and soft labels.

    Parameters:

      data (fetch_data.Dataset) – Dataset containing labels.

  predict(data)

    Add sensitive attribute predicton for hard and soft labels.

    Parameters:

      data (fetch_data.Dataset) – Dataset containing labels.

    Returns:

      Dataset with predicted sensitive attribute.

    Return type:

      fetch_data.Dataset

class synthetic_aia_mia.aia.Hard

  Bases: `object`

  Attribute inference attack of hard labels for adult.

  fit(dadata)

    Fit a finit classifier to predict sensitive attribute from hard labels.

    Parameters:

      dadata (fetch_data.Dataset) – Auxiliary data for aia training.

  predict(dadata)

    Use previously trained finit classifier to infer senstivies attribute and append prediction to input data.

    Parameters:

      dadata (fetch_data.Dataset) – Auxiliary data for aia evaluation.

    Returns:

      Dataset with aia prediction under the columns “sexAIAhard” and “raceAIAhard”.

    Return type:

      fetch_data.Dataset

class synthetic_aia_mia.aia.Soft

  Bases: `object`

  Attribute inference attack of soft labels for adult.

  fit(dadata)

    Fit a neural network to predict sensitive attribute from soft labels.

    Parameters:

      dadata (fetch_data.Dataset) – Auxiliary data for aia training.

  predict(dadata)

    Use previously trained neural network to infer senstivies attribute and append prediction to input data.

    Parameters:

      dadata (fetch_data.Dataset) – Auxiliary data for aia evaluation.

    Returns:

      Dataset with aia prediction under the columns “sexAIAsoft” and “raceAIAsoft”.

    Return type:

      fetch_data.Dataset