Esempio n. 1
0
func (v *ArrayVector) ToString() []byte {
	sb := util.StringBuilder{}
	for _, value := range v.data {
		sb.Float(value)
		sb.Write("|")
	}
	return sb.Bytes()
}
Esempio n. 2
0
func (self *LinearSVM) SaveModel(path string) {
	sb := util.StringBuilder{}
	for f, g := range self.w.Data {
		sb.Int64(f)
		sb.Write("\t")
		sb.Float(g)
		sb.Write("\n")
	}
	sb.WriteToFile(path)
}
Esempio n. 3
0
func (v *Vector) ToString() []byte {
	sb := util.StringBuilder{}
	for key, value := range v.Data {
		sb.Int64(key)
		sb.Write(":")
		sb.Float(value)
		sb.Write("|")
	}
	return sb.Bytes()
}
Esempio n. 4
0
func (s *Sample) ToString(includePrediction bool) []byte {
	sb := util.StringBuilder{}
	sb.Int(s.Label)
	sb.Write(" ")
	if includePrediction {
		sb.Float(s.Prediction)
		sb.Write(" ")
	}
	for _, feature := range s.Features {
		sb.Int64(feature.Id)
		sb.Write(":")
		sb.Float(feature.Value)
		sb.Write(" ")
	}
	return sb.Bytes()
}
Esempio n. 5
0
func (t *Tree) ToString() []byte {
	sb := util.StringBuilder{}
	sb.Int(len(t.nodes))
	sb.Write("\n")
	for i, node := range t.nodes {
		sb.Int(i)
		sb.Write("\t")
		sb.Int(node.left)
		sb.Write("\t")
		sb.Int(node.right)
		sb.Write("\t")
		sb.Int(node.depth)
		sb.Write("\t")
		sb.WriteBytes(node.prediction.ToString())
		sb.Write("\t")
		sb.Int(node.sample_count)
		sb.Write("\t")
		sb.Int64(node.feature_split.Id)
		sb.Write("\t")
		sb.Float(node.feature_split.Value)
		sb.Write("\n")
	}
	return sb.Bytes()
}