예제 #1
0
파일: problem.go 프로젝트: postfix/gosvm
func cNodes(nodes []FeatureValue) *C.svm_node_t {
	n := C.gosvm_nodes_new(C.size_t(len(nodes)))

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

	return n
}
예제 #2
0
파일: problem.go 프로젝트: postfix/gosvm
func (problem *Problem) Add(trainInst TrainingInstance) {
	features := sortedFeatureVector(trainInst.Features)

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

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

	C.gosvm_problem_add_train_inst(problem.problem, nodes, C.double(trainInst.Label))
}