Exemplo n.º 1
0
func cNodes(nodes []FeatureValue) *C.svm_node_t {
	n := C.nodes_new(C.size_t(len(nodes)))

	for idx, val := range nodes {
		C.nodes_put(n, C.size_t(idx), C.int(val.Index), C.double(val.Value))
	}

	return n
}
Exemplo n.º 2
0
func (problem *Problem) Add(trainInst TrainingInstance) {
	features := sortedFeatureVector(trainInst.Features)

	nodes := C.nodes_new(C.size_t(len(features)))

	for idx, val := range features {
		C.nodes_put(nodes, C.size_t(idx), C.int(val.Index), C.double(val.Value))
	}

	C.problem_add_train_inst(problem.problem, nodes, C.double(trainInst.Label))
}
Exemplo n.º 3
0
func newNodes(n C.size_t) *C.feature_node_t {
	nodes := tryNew(func() unsafe.Pointer {
		return unsafe.Pointer(C.nodes_new(n))
	})
	return (*C.feature_node_t)(nodes)
}