예제 #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
	}
}
예제 #2
0
import (
	"code.google.com/p/gomock/gomock"
	bt "github.com/brysgo/gofigure/binary_tree"
	dt "github.com/brysgo/gofigure/decision_tree"
	. "github.com/onsi/ginkgo"
	"github.com/onsi/ginkgo/thirdparty/gomocktestreporter"
	. "github.com/onsi/gomega"
	mbt "gofigure_mocks/mock_binary_tree"
	mdt "gofigure_mocks/mock_decision_tree"
	mil "gofigure_mocks/mock_input_log"
)

var (
	mockCtrl        *gomock.Controller
	myTree          dt.Interface
	mockBinaryTree  *mbt.MockInterface
	binaryTreeNew   func() bt.Interface = bt.New
	decisionTreeNew func() dt.Interface = dt.New
)

var _ = Describe("DecisionTree", func() {
	BeforeEach(func() {
		mockCtrl = gomock.NewController(gomocktestreporter.New())
		mockBinaryTree = mbt.NewMockInterface(mockCtrl)
		bt.New = func() bt.Interface {
			return mockBinaryTree
		}
		myTree = dt.New()
	})

	AfterEach(func() {
예제 #3
0
package decision_tree_test

import (
	dt "github.com/brysgo/gofigure/decision_tree"
	il "github.com/brysgo/gofigure/input_log"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("DecisionTree", func() {

	var id3InputSet il.InputLog
	var myTree dt.Interface

	BeforeEach(func() {
		id3InputSet = il.InputLog{
			{"1", "3"},
			{"0", "1", "3"},
			{"1", "3"},
			{"0", "1", "3"},
			{"1", "2"},
			{"0", "1", "2"},
			{},
			{"0"},
		}

		myTree = dt.New()
		myTree.Train(il.Interface(id3InputSet), "3")
	})

	Describe("Training a Decision Tree", func() {