Ejemplo n.º 1
0
	BeforeEach(func() {
		inputSet = il.InputLog{
			{},
			{"0", "1", "3"},
			{"1", "3"},
			{"0", "3"},
			{"0", "1", "2", "3"},
			{"0", "1", "3"},
			{"0", "1"},
			{"0", "2", "4"},
			{"2", "4"},
			{"4", "1"},
			{"0", "4", "2"},
		}

		myForest = pf.New()
		myForest.Train(il.Interface(inputSet))
	})

	Describe("Making a prediction", func() {
		It("adds a key that should be there", func() {
			Expect(myForest.Predict([]string{"0", "1"})).To(Equal([]string{"0", "1", "3"}))
		})

		It("removes a key that doesn't belong", func() {
			Expect(myForest.Predict([]string{"0", "1", "2", "3"})).To(Equal([]string{"0", "1", "3"}))
		})

		It("finds keys associated with a key", func() {
			Expect(myForest.Predict([]string{"4"})).To(Equal([]string{"0", "1", "2"}))
		})
Ejemplo n.º 2
0
				{"1", "2"},
				{"0", "1", "2"},
				{},
				{"0"},
			}

		})

		It("Builds a map of decision trees targeted at each input", func() {
			gomock.InOrder(
				mockDecisionTree.EXPECT().Train(gomock.Any(), gomock.Any()),
				mockDecisionTree.EXPECT().Train(gomock.Any(), gomock.Any()),
				mockDecisionTree.EXPECT().Train(gomock.Any(), gomock.Any()),
				mockDecisionTree.EXPECT().Train(gomock.Any(), gomock.Any()),
			)
			myForest = pf.New().(*pf.PredictionForest)
			myForest.Train(predictionForestInputSet)
		})

	})

	Describe("Predict", func() {
		var (
			mockHelloTree, mockWorldTree *mdt.MockInterface
		)

		BeforeEach(func() {
			mockHelloTree = mdt.NewMockInterface(mockCtrl)
			mockWorldTree = mdt.NewMockInterface(mockCtrl)
			myForest = pf.New().(*pf.PredictionForest)
			myForest.Trees["hello"] = mockHelloTree