Ejemplo n.º 1
0
    def instance(source_uri, random_seed=0):
        relation_helper = RelationHelper(source_uri)
        private_manager = kernel.PrivateManager(relation_helper.filename,
                                                relation_helper.config,
                                                random_seed=random_seed)
        kernel_service = pservice.KernelService(private_manager)

        return ProtectedDataSource(kernel_service,
                                   DataManager(transformation.Null()))
Ejemplo n.º 2
0
def Kernel(eps_total, random_seed):
    """ In an actual deployment, this code would be run on a
        private server with access to the unaltered data.
    """
    # Location of csv data file
    filename = os.path.join(CSV_PATH, 'cps.csv')

    # Configuration for data
    config_file = os.path.join(CONFIG_PATH, 'cps.yml')
    config = yaml.load(open(config_file, 'r').read())['cps_config']

    # Private manager (or kernel) guards access to data
    private_manager = kernel.PrivateManager(filename,
                                            config,
                                            random_seed=random_seed,
                                            budget=eps_total)

    # Kernel service mediates server-side access to kernel
    kernel_service = pservice.KernelService(private_manager)

    return kernel_service
Ejemplo n.º 3
0
CSV_PATH = os.environ['EKTELO_DATA']
CONFIG_PATH = os.path.join(os.environ['EKTELO_HOME'], 'resources', 'config')

# Setup arbitrary private constants
eps_total = 0.1
random_seed = 10

# Setup protected data source
filename =  os.path.join(CSV_PATH, 'cps.csv')
config_file = os.path.join(CONFIG_PATH, 'cps.yml')
config = yaml.load(open(config_file, 'r').read())['cps_config']
private_manager = kernel.PrivateManager(filename, 
                                        config, 
                                        random_seed=random_seed, 
                                        budget=eps_total)
kernel_service = pservice.KernelService(private_manager)
R = cservice.ProtectedDataSource(kernel_service)

# Choose reduced domain for relation
domain = (10, 1, 7, 1, 1)

# Vectorize relation
x = R.vectorize(domain)

# Setup arbitrary constants for MWEM
ratio = 0.5
rounds = 3
data_scale = 1e5
use_history = True
epsilon = eps_total / 2