godiffpriv

package module
v0.0.0-...-ee998bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2020 License: MIT Imports: 8 Imported by: 0

README

The module godiffpriv

Godiffpriv is a golang module for help to work differential privacy in golang projects. The module has support to queries with numeric and symbolic values. Besides, we apply the probability Laplace distribution to generate a random numbers.

How it works?
Data Type:
  • Numeric data should be float64 array
  • Symbolic data should be string array
How to use?
Install:

go get github.com/eriksonJAguiar/godiffpriv

Import:

import "github.com/eriksonJAguiar/godiffpriv"

Hello world:
  • For symbolic data:
	package main

	import (
		"encoding/json"
		"fmt"
		"github.com/eriksonJAguiar/godiffpriv"
	)
	
	func main() {
		data := []string{"Male", "Female", "Male", "Female"}
		val := godiffpriv.PrivateDataFactory(data)
		epsilon:= 1
		res, _ := val.ApplyPrivacy(epsilon)

		var response map[string]float64

		err := json.Unmarshal(res, &response)

		if err != nil {
			fmt.Println(err.Error())
		} else {
			fmt.Println(response)
		}
	}
  • For numeric data:
  	package main

	import (
		"encoding/json"
		"fmt"
		"github.com/eriksonJAguiar/godiffpriv"
	)
	
	func main() {
		data := []float64{1.5, 2.3, 7.2, 9.1}
		val := godiffpriv.PrivateDataFactory(data)
		epsilon:= 1
		res, _ := val.ApplyPrivacy(epsilon)

		var response map[string]float64

		err := json.Unmarshal(res, &response)

		if err != nil {
			fmt.Println(err.Error())
		} else {
			fmt.Println(response)
		}
	}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Privatevalue

type Privatevalue interface {
	ApplyPrivacy(float64) ([]byte, error)
}

Privatevalue is a interface to represents a private values to implements the object factory

func PrivateDataFactory

func PrivateDataFactory(dataset interface{}) Privatevalue

PrivateDataFactory is a factory method to generate private objects Params: dataset: a string to describes object type Returns: object to numeric or symbolic data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL