sigo

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Anonymize

func Anonymize(source RecordSource, factory GeneralizerFactory,
	k int, l int, dim int, anonymyzer Anonymizer, sink RecordSink, debugger Debugger) error

func BoxMuller added in v0.2.0

func BoxMuller() (float64, float64)

BoxMuller generates pairs of independent random numbers following a normal distribution. (https://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform).

func Contains added in v0.3.0

func Contains(slice []string, str string) bool

Contains return true if str is in slice.

func Exist added in v0.3.0

func Exist(filename string) bool

Exist return true if the file is present in the current directory.

func ExpNumber

func ExpNumber(mean float64) float64

ExpNumber generates safe exponential random value. (https://dzone.com/articles/generating-laplace-distributed-random-values).

func GaussianNumber

func GaussianNumber(loc float64, scale float64) float64

GaussianNumber generates safe Gaussian value.

func IQR

func IQR(values []float64) float64

IQR returns the interquartile range of values (Q3-Q1).

func LaplaceNumber

func LaplaceNumber() float64

LaplaceNumber generates Laplace value. (https://dzone.com/articles/generating-laplace-distributed-random-values).

func Max added in v0.2.0

func Max(listValues []float64) float64

Max returns the max value of listValues.

func Mean

func Mean(listValues []float64) (m float64)

Mean returns the mean value of listValues.

func Median

func Median(listValues []float64) (m float64)

Median returns the median value of listValues.

func Min added in v0.2.0

func Min(listValues []float64) float64

Min returns the min value of listValues.

func NewNode added in v0.2.0

func NewNode(tree *KDTree, path string, rot int) node

nolint: revive, golint

func RandFloat added in v0.2.0

func RandFloat() (float64, error)

Returns a secure random float in [0,1).

func RandInt added in v0.3.0

func RandInt(max int64) (int, error)

Returns a secure random integer in [0,max).

func Rescaling added in v0.2.0

func Rescaling(value float64, listValues []float64, method string) (rescale float64)

Rescaling returns the resize value.

func Scaling added in v0.2.0

func Scaling(value float64, listValues []float64, method string) float64

Scaling returns the scaled value to range [-2;2] for Laplace number and [-1;1] for Gaussian Number. (https://en.wikipedia.org/wiki/Normalization_(statistics)). If no method is mentioned, standardization is used.

func Shuffle added in v0.3.0

func Shuffle(s []float64) []float64

Secure shuffle of the order of the elements.

func Std

func Std(listValues []float64) (s float64)

Std returns the standard deviation of listValues. (https://fr.wikipedia.org/wiki/%C3%89cart_type).

func Sum

func Sum(listValues []float64) (sum float64)

Sum returns the sum of the elements of listValues.

Types

type AggregationAnonymizer

type AggregationAnonymizer struct {
	// contains filtered or unexported fields
}

func NewAggregationAnonymizer

func NewAggregationAnonymizer(typeAgg string) AggregationAnonymizer

func (AggregationAnonymizer) Anonymize

func (a AggregationAnonymizer) Anonymize(rec Record, clus Cluster, qi, s []string) Record

Anonymize returns the record anonymized with the method meanAggregarion or medianAggregation the record takes the aggregated values of the cluster.

func (AggregationAnonymizer) ComputeAggregation added in v0.1.1

func (a AggregationAnonymizer) ComputeAggregation(clus Cluster, qi []string)

ComputeAggregation calculates the mean (method meanAggreagtion) or median (method medianAggregation) value of the cluster for each qi.

type AnonymizedRecord

type AnonymizedRecord struct {
	// contains filtered or unexported fields
}

func (AnonymizedRecord) QuasiIdentifer

func (ar AnonymizedRecord) QuasiIdentifer() []float64

func (AnonymizedRecord) Row

func (ar AnonymizedRecord) Row() map[string]interface{}

func (AnonymizedRecord) Sensitives

func (ar AnonymizedRecord) Sensitives() []interface{}

type Anonymizer

type Anonymizer interface {
	Anonymize(Record, Cluster, []string, []string) Record
}

type Cluster

type Cluster interface {
	Records() []Record
	ID() string
	Bounds() []bounds
}

type CodingAnonymizer

type CodingAnonymizer struct{}

func NewCodingAnonymizer

func NewCodingAnonymizer() CodingAnonymizer

func (CodingAnonymizer) Anonymize

func (a CodingAnonymizer) Anonymize(rec Record, clus Cluster, qi, s []string) Record

Anonymize returns the record anonymized with the method outlier if the record is in the interval [Q1;Q3] then we don't change its value if the record is > Q3 then it takes the Q3 value if the record is < Q1 then it takes the Q1 value.

type Debugger

type Debugger interface {
	Information(Record, Cluster) Record
}

func NewNoDebugger

func NewNoDebugger() Debugger

type Definition added in v0.3.0

type Definition struct {
	Version     string   `yaml:"version"`
	K           int      `yaml:"kAnonymity"`
	L           int      `yaml:"lDiversity"`
	Sensitive   []string `yaml:"sensitives"`
	Aggregation string   `yaml:"aggregation"`
	Rules       []Rules  `yaml:"rules"`
}

func LoadConfigurationFromYAML added in v0.3.0

func LoadConfigurationFromYAML(filename string) (Definition, error)

LoadConfigurationFromYAML returns the configuration of the yaml file in a Definition object.

type GeneralAnonymizer

type GeneralAnonymizer struct {
	// contains filtered or unexported fields
}

func NewGeneralAnonymizer

func NewGeneralAnonymizer() GeneralAnonymizer

func (GeneralAnonymizer) Anonymize

func (a GeneralAnonymizer) Anonymize(rec Record, clus Cluster, qi, s []string) Record

Anonymize returns the record anonymize with the method general the record takes the bounds of the cluster.

type Generalizer

type Generalizer interface {
	Add(Record)
	Clusters() []Cluster
	String() string
	Build()
}

type GeneralizerFactory

type GeneralizerFactory interface {
	New(k int, l int, dim int, qi []string) Generalizer
}

type InfosRecord

type InfosRecord struct {
	// contains filtered or unexported fields
}

func (InfosRecord) QuasiIdentifer

func (ir InfosRecord) QuasiIdentifer() []float64

func (InfosRecord) Row

func (ir InfosRecord) Row() map[string]interface{}

func (InfosRecord) Sensitives

func (ir InfosRecord) Sensitives() []interface{}

type KDTree

type KDTree struct {
	// contains filtered or unexported fields
}

func NewKDTree added in v0.2.0

func NewKDTree(k, l, dim int, clusterID map[string]int) KDTree

func (KDTree) Add

func (t KDTree) Add(r Record)

Add add a record to the tree (root node).

func (KDTree) Build

func (t KDTree) Build()

Build starts building the tree.

func (KDTree) Clusters

func (t KDTree) Clusters() []Cluster

Clusters returns the list of clusters in the tree.

func (KDTree) String

func (t KDTree) String() string

String returns the tree in a literary way.

type KDTreeFactory

type KDTreeFactory struct{}

func NewKDTreeFactory

func NewKDTreeFactory() KDTreeFactory

func (KDTreeFactory) New

func (f KDTreeFactory) New(k int, l int, dim int, qi []string) Generalizer

type NoAnonymizer

type NoAnonymizer struct{}

func NewNoAnonymizer

func NewNoAnonymizer() NoAnonymizer

func (NoAnonymizer) Anonymize

func (a NoAnonymizer) Anonymize(rec Record, clus Cluster, qi, s []string) Record

Anonymize returns the original record, there is no anonymization.

type NoDebugger

type NoDebugger struct{}

func (NoDebugger) Information

func (d NoDebugger) Information(rec Record, cluster Cluster) Record

type NoiseAnonymizer

type NoiseAnonymizer struct {
	// contains filtered or unexported fields
}

func NewNoiseAnonymizer

func NewNoiseAnonymizer(mechanism string) NoiseAnonymizer

func (NoiseAnonymizer) Anonymize

func (a NoiseAnonymizer) Anonymize(rec Record, clus Cluster, qi, s []string) Record

Anonymize returns the record anonymized with the method laplaceNoise or gaussianNoise the record takes as value the original value added to a Laplacian or Gaussian noise the anonymized value stays within the bounds of the cluster.

type Quartiles

type Quartiles struct {
	Q1 float64
	Q2 float64
	Q3 float64
}

func Quartile

func Quartile(values []float64) Quartiles

Quartile returns the 1st quartile, 2nd quartile (median) and 3rd quartile of values.

type Record

type Record interface {
	QuasiIdentifer() []float64
	Sensitives() []interface{}
	Row() map[string]interface{}
}

type RecordSink

type RecordSink interface {
	Collect(Record) error
}

type RecordSource

type RecordSource interface {
	Next() bool
	Err() error
	Value() Record
	QuasiIdentifer() []string
	Sensitive() []string
}

type Rules added in v0.3.0

type Rules struct {
	Name string `yaml:"name"`
}

type SequenceDebugger

type SequenceDebugger struct {
	// contains filtered or unexported fields
}

func NewSequenceDebugger

func NewSequenceDebugger(key string) SequenceDebugger

func (SequenceDebugger) Information

func (d SequenceDebugger) Information(rec Record, cluster Cluster) Record

Information returns an InfosRecord which is a record with the identifier of the cluster in which the record rec is located.

type SwapAnonymizer added in v0.3.0

type SwapAnonymizer struct {
	// contains filtered or unexported fields
}

func NewSwapAnonymizer added in v0.3.0

func NewSwapAnonymizer() SwapAnonymizer

func (SwapAnonymizer) Anonymize added in v0.3.0

func (a SwapAnonymizer) Anonymize(rec Record, clus Cluster, qi, s []string) Record

func (SwapAnonymizer) Swap added in v0.3.0

func (a SwapAnonymizer) Swap(clus Cluster, qi []string)

Jump to

Keyboard shortcuts

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