示例#1
0
文件: scores.go 项目: timtadh/sfp
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
}
示例#2
0
文件: mine.go 项目: timtadh/sfp
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)
}
示例#3
0
文件: mine.go 项目: timtadh/sfp
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
}