本文整理汇总了Golang中github.com/xlvector/hector/core.Sample类的典型用法代码示例。如果您正苦于以下问题:Golang Sample类的具体用法?Golang Sample怎么用?Golang Sample使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sample类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Predict
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: Predict
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: PredictMultiClass
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: PredictMultiClass
func (c *KNN) PredictMultiClass(sample *core.Sample) *core.ArrayVector {
x := sample.GetFeatureVector()
predictions := []*eval.LabelPrediction{}
for i, s := range c.sv {
predictions = append(predictions, &(eval.LabelPrediction{Label: c.labels[i], Prediction: c.Kernel(s, x)}))
}
compare := func(p1, p2 *eval.LabelPrediction) bool {
return p1.Prediction > p2.Prediction
}
eval.By(compare).Sort(predictions)
ret := core.NewArrayVector()
for i, pred := range predictions {
if i > c.k {
break
}
ret.AddValue(pred.Label, 1.0)
}
return ret
}
示例5: Predict
func (c *SVM) Predict(sample *core.Sample) float64 {
x := sample.GetFeatureVector()
return c.PredictVector(x)
}
示例6: PredictMultiClass
func (dt *CART) PredictMultiClass(sample *core.Sample) *core.ArrayVector {
msample := sample.ToMapBasedSample()
node, _ := PredictBySingleTree(&dt.tree, msample)
return node.prediction
}
示例7: Predict
func (dt *CART) Predict(sample *core.Sample) float64 {
msample := sample.ToMapBasedSample()
node, _ := PredictBySingleTree(&dt.tree, msample)
return node.prediction.GetValue(1)
}
示例8: Predict
func (dt *RegressionTree) Predict(sample *core.Sample) float64 {
msample := sample.ToMapBasedSample()
node, _ := dt.PredictBySingleTree(&dt.tree, msample)
return node.prediction.GetValue(0)
}