Example #1
0
		}
		myTree = dt.New()
	})

	AfterEach(func() {
		mockCtrl.Finish()

		bt.New = binaryTreeNew
		dt.New = decisionTreeNew
	})

	Describe("#Train", func() {
		var (
			inputLog, leftInputLog, rightInputLog *mil.MockInterface
			targetKey, nextKey                    string
			maxEntropyCall                        *gomock.Call
			keyCountCall                          *gomock.Call
			leftDecisionTree, rightDecisionTree   *mdt.MockInterface
			keySetCall, leftAnyCall, rightAnyCall *gomock.Call
		)

		BeforeEach(func() {
			inputLog = mil.NewMockInterface(mockCtrl)
			targetKey = "the target key"

			leftInputLog = mil.NewMockInterface(mockCtrl)
			rightInputLog = mil.NewMockInterface(mockCtrl)

			maxEntropyCall = inputLog.EXPECT().MaxEntropy(targetKey)
		})

		Describe("when there are no features left to decide on", func() {
		decisionTreeNew func() dt.Interface
	)

	BeforeEach(func() {
		decisionTreeNew = dt.New
		mockCtrl = gomock.NewController(gomocktestreporter.New())
	})

	AfterEach(func() {
		dt.New = decisionTreeNew
		mockCtrl.Finish()
	})

	Describe("Train", func() {
		var (
			predictionForestInputSet il.InputLog
			mockDecisionTree         *mdt.MockInterface
		)

		BeforeEach(func() {
			mockDecisionTree = mdt.NewMockInterface(mockCtrl)
			dt.New = func() dt.Interface {
				return mockDecisionTree
			}
			predictionForestInputSet = il.InputLog{
				{"1", "3"},
				{"0", "1", "3"},
				{"1", "3"},
				{"0", "1", "3"},
				{"1", "2"},
				{"0", "1", "2"},
				{},