コード例 #1
0
func (rdt *RandomDecisionTree) Predict(sample * core.Sample) float64 {
	ret := 0.0
	total := 0.0
	msample := sample.ToMapBasedSample()
	for _,tree := range rdt.trees{
		node, _ := PredictBySingleTree(tree, msample)
		ret += node.prediction.GetValue(1)
		total += 1.0
	}	
	return ret / total
}
コード例 #2
0
ファイル: random_forest.go プロジェクト: julycoding/hector
func (dt *RandomForest) Predict(sample *core.Sample) float64 {
	msample := sample.ToMapBasedSample()
	predictions := 0.0
	total := 0.0
	for _, tree := range dt.trees {
		node, _ := PredictBySingleTree(tree, msample)
		predictions += node.prediction.GetValue(1)
		total += 1.0
	}
	return predictions / total
}
コード例 #3
0
func (rdt *RandomDecisionTree) PredictMultiClass(sample * core.Sample) *core.ArrayVector {
	msample := sample.ToMapBasedSample()
	predictions := core.NewArrayVector()
	total := 0.0
	for _, tree := range rdt.trees{
		node, _ := PredictBySingleTree(tree, msample)
		predictions.AddVector(node.prediction, 1.0)
		total += 1.0
	}
	predictions.Scale(1.0 / total)
	return predictions
}
コード例 #4
0
ファイル: cart.go プロジェクト: julycoding/hector
func (dt *CART) PredictMultiClass(sample *core.Sample) *core.ArrayVector {
	msample := sample.ToMapBasedSample()
	node, _ := PredictBySingleTree(&dt.tree, msample)
	return node.prediction
}
コード例 #5
0
ファイル: cart.go プロジェクト: julycoding/hector
func (dt *CART) Predict(sample *core.Sample) float64 {
	msample := sample.ToMapBasedSample()
	node, _ := PredictBySingleTree(&dt.tree, msample)
	return node.prediction.GetValue(1)
}
コード例 #6
0
ファイル: regression_tree.go プロジェクト: julycoding/hector
func (dt *RegressionTree) Predict(sample * core.Sample) float64 {
	msample := sample.ToMapBasedSample()
	node,_ := dt.PredictBySingleTree(&dt.tree, msample)
	return node.prediction.GetValue(0)
}