backoff

package
v0.0.0-...-05931ac Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

README

Both backoff strategies fight the problem that too many given properties in the request result in no possibile recommendation, since inside the schematree no candiate node can be found that has all the properties from the request inside its prefix.

Delete Low Frequency Backoff

  1. Sort incoming request according to frequency
  2. Create subsets by deleting p times the i less frequent items, i variating according to the stepsize function
  3. Run p recommenders in parallel
  4. choose that one which satisfies the condition and deleted less number of properties

LinearStepsize: take away the least frequent property one after another (#parallelExecution times)

ProportionalStepsize: determine the least 40% of incoming property set. take away (1/#parallelExecutions) one after another.

Split Property Set

  1. Sort incoming properties according to their frequency (which we get from the tree)
  2. Split the property set into two subsets
  3. Perform recommendation on both subsets (in parallel which works brilliantly in go)
  4. Merge (avg or max)

Split strategies are:

EverySecondItem: The result are two more or less equally distrbuted sets in terms of property frequency

TwoFreqeuncyRanges: The result are two sets, one containing all the high frequent properties, the other all the lows.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AvgMerger = func(recommendations []ST.PropertyRecommendations) (merged ST.PropertyRecommendations) {
	// create a map that stores pointers to all the values with the same property name
	var m map[string]([]ST.RankedPropertyCandidate) = make(map[string]([]ST.RankedPropertyCandidate))

	for _, recList := range recommendations {
		for _, rec := range recList {
			m[*(rec.Property.Str)] = append(m[*(rec.Property.Str)], rec)
		}
	}

	merged = make([]ST.RankedPropertyCandidate, 0, len(m))
	for _, recList := range m {
		var avg float64
		rec := recList[0]
		for _, r := range recList {
			avg = avg + r.Probability
		}
		rec.Probability = avg / float64(len(recommendations))
		merged = append(merged, rec)
	}

	sort.Slice(merged, func(i, j int) bool { return merged[i].Probability > merged[j].Probability })
	return
}

merge the recommendation sets and calculate the average over the recommendations.

View Source
var DummyMerger = func(recommendations []ST.PropertyRecommendations) (merged ST.PropertyRecommendations) {
	merged = recommendations[0]
	return
}

just chooses the first recommendation as final recommendation

View Source
var EverySecondItemSplitter = func(properties ST.IList) (sublists []ST.IList) {
	properties.Sort()
	sublists = make([]ST.IList, 2, 2)
	for i, p := range properties {
		if i%2 == 0 {
			sublists[0] = append(sublists[0], p)
		} else {
			sublists[1] = append(sublists[1], p)
		}
	}
	return
}

splits into two sublists. "Equal" mixture of high and low support properties in both sets.

View Source
var MaxMerger = func(recommendations []ST.PropertyRecommendations) (merged ST.PropertyRecommendations) {
	var m map[string]ST.RankedPropertyCandidate = make(map[string]ST.RankedPropertyCandidate)

	for _, recList := range recommendations {
		for _, rec := range recList {
			rMap := m[*rec.Property.Str]
			if rMap.Probability < rec.Probability {
				m[*rec.Property.Str] = rec
			}
		}
	}

	merged = make([]ST.RankedPropertyCandidate, 0, len(m))
	for _, rec := range m {
		merged = append(merged, rec)
	}

	sort.Slice(merged, func(i, j int) bool { return merged[i].Probability > merged[j].Probability })
	return
}

merge the recommendation sets. If a property was recommended in multiple sets then choose the maximum likelihood as returned recommendation.

View Source
var StepsizeLinear = func(size, iterator, parallelExecutions int) int {
	if iterator < size {
		return iterator
	}
	return size - 1
}

step size function literals for defining how many items should be removed. linear removal: f(x) = x

View Source
var StepsizeProportional = func(size, iterator, parallelExecutions int) int {
	return int(math.Round(0.4 * float64(iterator) / float64(parallelExecutions) * float64(size)))
}

proportional removal up to 30% of all items

View Source
var TwoSupportRangesSplitter = func(properties ST.IList) (sublists []ST.IList) {
	properties.Sort()
	sublists = make([]ST.IList, 2, 2)
	mid := int(float64(len(properties)) / 2.0)
	sublists[0] = properties[mid:]
	sublists[1] = properties[:mid]
	return
}

splits the data set into two equally sized sublists, one containing all the high support properties, and one all the low support properties.

Functions

This section is empty.

Types

type BackoffDeleteLowFrequencyItems

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

func NewBackoffDeleteLowFrequencyItems

func NewBackoffDeleteLowFrequencyItems(pTree *ST.SchemaTree, pParallelExecutions int, pStepsize StepsizeFunc, pCondition InternalCondition) *BackoffDeleteLowFrequencyItems

NewBackoffDeleteLowFrequencyItems : constructor method

func (*BackoffDeleteLowFrequencyItems) Recommend

func (strat *BackoffDeleteLowFrequencyItems) Recommend(propertyList ST.IList) (ranked ST.PropertyRecommendations)

Recommend a propertyRecommendations list with the delete low Frequency Property Backoff strategy

type BackoffSplitPropertySet

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

BackoffSplitPropertySet holds all information necessary to execute the algorithm

func NewBackoffSplitPropertySet

func NewBackoffSplitPropertySet(pTree *ST.SchemaTree, pSplitter SplitterFunc, pMerger MergerFunc) *BackoffSplitPropertySet

NewBackoffSplitPropertySet : constructor method

func (*BackoffSplitPropertySet) Recommend

func (strat *BackoffSplitPropertySet) Recommend(propertyList ST.IList) (ranked ST.PropertyRecommendations)

Recommend a propertyRecommendations list with the delete low Frequency Property Backoff strategy

type InternalCondition

type InternalCondition func(*ST.PropertyRecommendations) bool

func MakeMoreThanInternalCondition

func MakeMoreThanInternalCondition(threshold int) InternalCondition

func MakeMoreThanProbabilityInternalCondition

func MakeMoreThanProbabilityInternalCondition(threshold float32) InternalCondition

type SplitterFunc

type SplitterFunc func(ST.IList) []ST.IList

type StepsizeFunc

type StepsizeFunc func(int, int, int) int

Jump to

Keyboard shortcuts

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