Exemplo n.º 1
0
// Get a slice with class labels
func (model *Model) labels() []int {
	nClasses := C.svm_get_nr_class_wrap(model.model)
	cLabels := C.labels_new(nClasses)
	defer C.free(unsafe.Pointer(cLabels))
	C.svm_get_labels_wrap(model.model, cLabels)

	labels := make([]int, int(nClasses))

	for idx, _ := range labels {
		labels[idx] = int(C.get_int_idx(cLabels, C.int(idx)))
	}

	return labels
}
Exemplo n.º 2
0
func newLabels(n C.int) *C.int {
	labels := tryNew(func() unsafe.Pointer {
		return unsafe.Pointer(C.labels_new(n))
	})
	return (*C.int)(labels)
}