Пример #1
0
//
// refillWithFP will copy the false-positive data in training set `tnset`
// and append it to `samples`.
//
func (crf *Runtime) refillWithFP(samples, tnset tabula.ClasetInterface,
	cm *classifier.CM,
) {
	// Get and sort FP.
	fpids := cm.FPIndices()
	sort.Ints(fpids)

	// Move FP samples from TN-set to training set samples.
	for _, i := range fpids {
		samples.PushRow(tnset.GetRow(i))
	}

	// Delete FP from training set.
	var row *tabula.Row
	c := 0
	for x, i := range fpids {
		row = tnset.DeleteRow(i - x)
		if row != nil {
			c++
		}
	}

	if DEBUG >= 1 {
		fmt.Println(tag, "# FP", len(fpids), "# refilled", c)
	}
}
Пример #2
0
func (crf *Runtime) deleteTrueNegative(samples tabula.ClasetInterface,
	cm *classifier.CM,
) {
	var row *tabula.Row

	tnids := cm.TNIndices()
	sort.Ints(tnids)

	// (1)
	if len(crf.weights) <= 1 {
		for _, i := range tnids {
			crf.tnset.PushRow(samples.GetRow(i))
		}
	}

	// (2)
	c := 0
	for x, i := range tnids {
		row = samples.DeleteRow(i - x)
		if row != nil {
			c++
		}
	}

	if DEBUG >= 1 {
		fmt.Println(tag, "# TN", len(tnids), "# deleted", c)
	}
}