func (q *WalkKernel) Score(n lattice.Node, population []lattice.Node) float64 { sampleSize := 10 mean, _ := stats.Mean(stats.Sample(sampleSize, len(population)), func(i int) float64 { o := population[i] return n.(*digraph.EmbListNode).Pat.Metric(o.(*digraph.EmbListNode).Pat) }) return mean }
func (m *Miner) takeOne(queue []lattice.Node) ([]lattice.Node, lattice.Node) { s := stats.Sample(10, len(queue)) k := m.Scorer.Kernel(queue, s) var i int var ms float64 if len(k) > 0 { i, ms = stats.Max(stats.Srange(len(k)), func(i int) float64 { return k.Mean(i) }) i = s[i] } else { i, ms = stats.Max(s, func(i int) float64 { return m.Scorer.Score(queue[i], queue) }) } errors.Logf("DEBUG", "max score %v, queue len %v, taking %v", ms, len(queue), queue[i]) return pop(queue, i) }
func (m *Miner) dropOne(queue []lattice.Node) []lattice.Node { s := stats.Sample(10, len(queue)) k := m.Scorer.Kernel(queue, s) var i int var ms float64 if len(k) > 0 { i, ms = stats.Min(stats.Srange(len(k)), func(i int) float64 { return k.Mean(i) }) i = s[i] } else { i, ms = stats.Min(s, func(i int) float64 { return m.Scorer.Score(queue[i], queue) }) } errors.Logf("DEBUG", "min score %v, queue len %v, dropping %v", ms, len(queue), queue[i]) queue, _ = pop(queue, i) return queue }