예제 #1
0
파일: crf.go 프로젝트: shuLhan/go-mining
//
// runTPSet will run true-positive set into trained stage, to get the
// false-positive. The FP samples will be added to training set.
//
func (crf *Runtime) runTPSet(samples tabula.ClasetInterface) {
	// Skip the first stage, because we just got tnset from them.
	if len(crf.weights) <= 1 {
		return
	}

	tnIds := numerus.IntCreateSeq(0, crf.tnset.Len()-1)
	_, cm, _ := crf.ClassifySetByWeight(crf.tnset, tnIds)

	crf.refillWithFP(samples, crf.tnset, cm)
}
예제 #2
0
//
// Performance given an actuals class label and their probabilities, compute
// the performance statistic of classifier.
//
// Algorithm,
// (1) Sort the probabilities in descending order.
// (2) Sort the actuals and predicts using sorted index from probs
// (3) Compute tpr, fpr, precision
// (4) Write performance to file.
//
func (rt *Runtime) Performance(samples tabula.ClasetInterface,
	predicts []string, probs []float64,
) (
	perfs Stats,
) {
	// (1)
	actuals := samples.GetClassAsStrings()
	sortedIds := numerus.IntCreateSeq(0, len(probs)-1)
	numerus.Floats64InplaceMergesort(probs, sortedIds, 0, len(probs),
		false)

	// (2)
	tekstus.StringsSortByIndex(&actuals, sortedIds)
	tekstus.StringsSortByIndex(&predicts, sortedIds)

	// (3)
	rt.computePerfByProbs(samples, actuals, probs)

	return rt.perfs
}