[#227] netmap: Remove unused aggregators and normalizers

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-06-07 08:58:59 +03:00 committed by LeL
parent 723ba5ee45
commit 6796b4a29a

View file

@ -17,11 +17,6 @@ type (
Normalize(w float64) float64 Normalize(w float64) float64
} }
meanSumAgg struct {
sum float64
count int
}
meanAgg struct { meanAgg struct {
mean float64 mean float64
count int count int
@ -31,10 +26,6 @@ type (
min float64 min float64
} }
maxAgg struct {
max float64
}
meanIQRAgg struct { meanIQRAgg struct {
k float64 k float64
arr []float64 arr []float64
@ -44,33 +35,21 @@ type (
min float64 min float64
} }
maxNorm struct {
max float64
}
sigmoidNorm struct { sigmoidNorm struct {
scale float64 scale float64
} }
constNorm struct {
value float64
}
// weightFunc calculates n's weight. // weightFunc calculates n's weight.
weightFunc = func(NodeInfo) float64 weightFunc = func(NodeInfo) float64
) )
var ( var (
_ aggregator = (*meanSumAgg)(nil)
_ aggregator = (*meanAgg)(nil) _ aggregator = (*meanAgg)(nil)
_ aggregator = (*minAgg)(nil) _ aggregator = (*minAgg)(nil)
_ aggregator = (*maxAgg)(nil)
_ aggregator = (*meanIQRAgg)(nil) _ aggregator = (*meanIQRAgg)(nil)
_ normalizer = (*reverseMinNorm)(nil) _ normalizer = (*reverseMinNorm)(nil)
_ normalizer = (*maxNorm)(nil)
_ normalizer = (*sigmoidNorm)(nil) _ normalizer = (*sigmoidNorm)(nil)
_ normalizer = (*constNorm)(nil)
) )
// newWeightFunc returns weightFunc which multiplies normalized // newWeightFunc returns weightFunc which multiplies normalized
@ -112,19 +91,6 @@ func newSigmoidNorm(scale float64) normalizer {
return &sigmoidNorm{scale: scale} return &sigmoidNorm{scale: scale}
} }
func (a *meanSumAgg) Add(n float64) {
a.sum += n
a.count++
}
func (a *meanSumAgg) Compute() float64 {
if a.count == 0 {
return 0
}
return a.sum / float64(a.count)
}
func (a *meanAgg) Add(n float64) { func (a *meanAgg) Add(n float64) {
c := a.count + 1 c := a.count + 1
a.mean = a.mean*(float64(a.count)/float64(c)) + n/float64(c) a.mean = a.mean*(float64(a.count)/float64(c)) + n/float64(c)
@ -145,16 +111,6 @@ func (a *minAgg) Compute() float64 {
return a.min return a.min
} }
func (a *maxAgg) Add(n float64) {
if n > a.max {
a.max = n
}
}
func (a *maxAgg) Compute() float64 {
return a.max
}
func (a *meanIQRAgg) Add(n float64) { func (a *meanIQRAgg) Add(n float64) {
a.arr = append(a.arr, n) a.arr = append(a.arr, n)
} }
@ -200,14 +156,6 @@ func (r *reverseMinNorm) Normalize(w float64) float64 {
return r.min / w return r.min / w
} }
func (r *maxNorm) Normalize(w float64) float64 {
if r.max == 0 {
return 0
}
return w / r.max
}
func (r *sigmoidNorm) Normalize(w float64) float64 { func (r *sigmoidNorm) Normalize(w float64) float64 {
if r.scale == 0 { if r.scale == 0 {
return 0 return 0
@ -217,7 +165,3 @@ func (r *sigmoidNorm) Normalize(w float64) float64 {
return x / (1 + x) return x / (1 + x)
} }
func (r *constNorm) Normalize(_ float64) float64 {
return r.value
}