Example #1
0
File: mom.go Project: 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)
	}
}
Example #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])
	}
}
Example #3
0
File: itm.go Project: 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)
		}
	}
}
Example #4
0
File: lda.go Project: 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)
		}
	}
}
Example #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])
	}
}
Example #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))
}
Example #7
0
File: itm.go Project: 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)
		}
	}
}