Exemplo n.º 1
0
Arquivo: node.go Projeto: timtadh/sfp
func (a *Pattern) Distance(p lattice.Pattern) float64 {
	b := p.(*Pattern)
	i, err := a.Items.Intersect(b.Items)
	exc.ThrowOnError(err)
	inter := float64(i.Size())
	return 1.0 - (inter / (float64(a.Items.Size()) + float64(b.Items.Size()) - inter))
}
Exemplo n.º 2
0
func jaccardSetSimilarity(a, b types.Set) float64 {
	i, err := a.Intersect(b)
	exc.ThrowOnError(err)
	inter := float64(i.Size())
	return 1.0 - (inter / (float64(a.Size()) + float64(b.Size()) - inter))
}