sigo

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: GPL-3.0 Imports: 17 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 Camberra added in v0.4.0

func Camberra(x, y map[string]float64) float64

Camberra compute the camberra distance.

func Chebyshev added in v0.4.0

func Chebyshev(x, y map[string]float64) float64

Chebyshev compute the chebyshev distance.

func ComputeDistance added in v0.4.0

func ComputeDistance(name string, x, y map[string]float64) float64

func Contains added in v0.3.0

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

Contains return true if str is in slice.

func Cosine added in v0.4.0

func Cosine(x, y map[string]float64) float64

Cosine compute the cosine distance.

func CountValues added in v0.4.0

func CountValues(sensitives []string) map[string]int

CountValues returns a map with the number of occurrences for each sensitive data value.

func Euclidean added in v0.4.0

func Euclidean(x, y map[string]float64) float64

Euclidean compute the euclidean distance.

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 Find added in v0.4.0

func Find(slice []string, val string) bool

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 IsUnique added in v0.4.0

func IsUnique(sensitives map[string][]interface{}) map[string]bool

IsUnique returns if the string slice contains unique values or not.

func LaplaceNumber

func LaplaceNumber() float64

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

func ListValues added in v0.4.0

func ListValues(data []map[string]interface{}, s []string) (mapValues map[string][]interface{})

Returns the list of values present in the slice of map[string]interface{}.

func Manhattan added in v0.4.0

func Manhattan(x, y map[string]float64) float64

Manhattan compute the manhatan distance.

func MapItoMapF added in v0.4.0

func MapItoMapF(m map[string]interface{}) map[string]float64

MapItoMapF convert a map[string]interface{} to a map[string]float64.

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 Minkowski added in v0.4.0

func Minkowski(x, y map[string]float64, p float64) float64

Minkowski compute the minkowski distance.

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 Scale added in v0.4.0

func Scale(value interface{}, mean float64, std float64) float64

Scale returns the scaled value to ensure the mean and the standard deviation to be 0 and 1, respectively.

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 Similarity added in v0.4.0

func Similarity(distance float64) float64

func SliceString added in v0.4.0

func SliceString(slice []interface{}) (res []string)

SliceString convert a slice of interface into a slice of string.

func SliceToFloat64 added in v0.4.0

func SliceToFloat64(slice []interface{}) (res []float64)

SliceToFloat64 convert a slice of interface into a slice of float64.

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.

func TopSimilarity added in v0.4.0

func TopSimilarity(s map[float64]interface{}) (float64, interface{})

func Unique added in v0.4.0

func Unique(slice []map[string]interface{}, qi []string) bool

Unique returns if the slice contains unique map[string]interface{} or not.

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
}

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.

func (GeneralAnonymizer) ComputeGeneralization added in v0.4.0

func (a GeneralAnonymizer) ComputeGeneralization(clus Cluster, qi []string)

ComputeGeneralization calculates the min and max values of the cluster for each qi.

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 Reidentification added in v0.4.0

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

func NewReidentification added in v0.4.0

func NewReidentification(args []string) Reidentification

func (Reidentification) Anonymize added in v0.4.0

func (r Reidentification) Anonymize(rec Record, clus Cluster, qi, s []string) Record

Anonymize on object Reidentification re-identifies the original data using the anonymized data.

func (Reidentification) ComputeSimilarity added in v0.4.0

func (r Reidentification) ComputeSimilarity(rec Record, clus Cluster,
	qi []string, s []string) map[float64]interface{}

ComputeSimilarity computes the similarity score between the record rec and the anonymized cluster data.

func (Reidentification) ComputeStatistics added in v0.4.0

func (r Reidentification) ComputeStatistics(data []map[string]interface{}, clus Cluster, s []string)

ComputeStatistics computes the mean and standart deviation for cluster clus.

func (Reidentification) InitReidentification added in v0.4.0

func (r Reidentification) InitReidentification(clus Cluster, qi []string, s []string)

InitReidentification initialize the re-identification object.

func (Reidentification) Statistics added in v0.4.0

func (r Reidentification) Statistics(idCluster string, q string) (mean float64, std float64)

Statistics returns the statistics of the q attribute of the cluster with path idCluster.

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