Esempio n. 1
0
File: mom.go Progetto: jlund3/modelt
func (m *MoM) CCM() {
	for d := 0; d < m.M; d++ {
		m.unsetZ(d)
		z := util.Argmax(m.conditional(d))
		m.setZ(d, z)
	}
}
Esempio n. 2
0
func (m *DPMoM) CCM() {
	for d := 0; d < m.M; d++ {
		m.unsetZ(d)
		lcounts, mapping := m.conditional(d)
		i := util.Argmax(lcounts)
		m.setZ(d, mapping[i])
	}
}
Esempio n. 3
0
File: itm.go Progetto: jlund3/modelt
func (i *ITM) CCM() {
	for _, d := range rand.Perm(i.M) {
		for n := 0; n < i.N[d]; n++ {
			i.unsetZ(d, n)
			z := util.Argmax(i.conditional(d, n))
			i.setZ(d, n, z)
		}
	}
}
Esempio n. 4
0
File: lda.go Progetto: jlund3/modelt
func (l *LDA) CCM() {
	for _, d := range rand.Perm(l.M) {
		for n := 0; n < l.N[d]; n++ {
			l.unsetZ(d, n)
			z := util.Argmax(l.conditional(d, n))
			l.setZ(d, n, z)
		}
	}
}
Esempio n. 5
0
func (m *DPMoM) SUGS() {
	for d := 0; d < m.M; d++ {
		m.setZ(d, unassignCluster)
	}
	for d := 0; d < m.M; d++ {
		lcounts, mapping := m.conditional(d)
		i := util.Argmax(lcounts)
		m.setZ(d, mapping[i])
	}
}
Esempio n. 6
0
func (b *NaiveBayes) Classify(data []int) interface{} {
	lposts := make([]float64, b.LabelIndex.Len())
	for label := range lposts {
		lpost := b.LabelCounts[label]
		for _, word := range data {
			lpost += b.WordCounts[label][word]
		}
		lposts[label] = lpost
	}
	return b.LabelIndex.Item(util.Argmax(lposts))
}
Esempio n. 7
0
File: itm.go Progetto: jlund3/modelt
func (i *ITM) Coinflip(pMax float64) {
	for _, d := range rand.Perm(i.M) {
		for n := 0; n < i.N[d]; n++ {
			i.unsetZ(d, n)
			var z int
			if rand.Float64() < pMax {
				z = util.Argmax(i.conditional(d, n))
			} else {
				z = util.SampleCounts(i.conditional(d, n))
			}
			i.setZ(d, n, z)
		}
	}
}