setsim

package module
v0.0.0-...-77e1715 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: MIT Imports: 1 Imported by: 0

README

go-setsim

Similarity coefficients of sets (Jaccard, Dice, Simpson)

Usage

func TestJaccard(t *testing.T) {
	s1 := mapset.NewSetFromSlice([]interface{}{"a", "b", "c", "d", "e"})
	s2 := mapset.NewSetFromSlice([]interface{}{"a", "b", "c", "g"})

	j := Jaccard(s1, s2)
	if j != 0.5 {
		t.Fatal("ng")
	}
}

func TestDice(t *testing.T) {
	s1 := mapset.NewSetFromSlice([]interface{}{"a", "b", "c", "d", "e", "f"})
	s2 := mapset.NewSetFromSlice([]interface{}{"a", "b", "c", "g"})

	d := Dice(s1, s2)
	if d != 0.6 {
		t.Fatal("ng")
	}
}

func TestSimpson(t *testing.T) {
	s1 := mapset.NewSetFromSlice([]interface{}{"a", "b", "c", "d", "e", "f"})
	s2 := mapset.NewSetFromSlice([]interface{}{"a", "b", "c", "g"})

	s := Simpson(s1, s2)
	if s != 0.75 {
		t.Fatal("ng")
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dice

func Dice(a, b mapset.Set) float64

func Jaccard

func Jaccard(a, b mapset.Set) float64

func Simpson

func Simpson(a, b mapset.Set) float64

Types

This section is empty.

Jump to

Keyboard shortcuts

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