Beispiel #1
0
func (self *PredictionForest) Train(inputLog il.Interface) {
	for _, key := range inputLog.Keys() {
		var newTree dt.Interface
		newTree = dt.New()
		newTree.Train(inputLog, key)
		self.Trees[key] = newTree
	}
}
Beispiel #2
0
func (self *DecisionTree) Train(inputLog il.Interface, targetKey string) {
	nextKey := inputLog.MaxEntropy(targetKey)
	if nextKey != targetKey {
		leftInputLog, rightInputLog := inputLog.SplitOnKey(nextKey)
		left, right := New(), New()
		if leftInputLog.Any() {
			left.Train(leftInputLog, targetKey)
		}
		if rightInputLog.Any() {
			right.Train(rightInputLog, targetKey)
		}
		self.InsertLeft(left)
		self.InsertRight(right)
		self.Set(nextKey)
	} else {
		present := inputLog.KeyCount(targetKey)
		absent := inputLog.Len() - present
		self.Set(present > absent)
	}
}