def _double_array(seq): size = len(seq) array = svmc.double_array(size) i = 0 for item in seq: svmc.double_set(array, i, item) i = i + 1 return array
def _double_array(seq): size = len(seq) array = svmc.double_array(size) i = 0 for item in seq: svmc.double_set(array,i,item) i = i + 1 return array
def __init__(self, y, x): assert len(y) == len(x) self.prob = prob = svmc.new_svm_problem() self.size = size = len(y) self.y_array = y_array = svmc.double_array(size) for i in range(size): svmc.double_set(y_array, i, y[i]) self.x_matrix = x_matrix = svmc.svm_node_matrix(size) self.data = [] self.maxlen = 0 for i in range(size): data = _convert_to_svm_node_array(x[i]) self.data.append(data) svmc.svm_node_matrix_set(x_matrix, i, data) self.maxlen = max(self.maxlen, len(x[i])) svmc.svm_problem_l_set(prob, size) svmc.svm_problem_y_set(prob, y_array) svmc.svm_problem_x_set(prob, x_matrix)
def __init__(self,y,x): assert len(y) == len(x) self.prob = prob = svmc.new_svm_problem() self.size = size = len(y) self.y_array = y_array = svmc.double_array(size) for i in range(size): svmc.double_set(y_array,i,y[i]) self.x_matrix = x_matrix = svmc.svm_node_matrix(size) self.data = [] self.maxlen = 0; for i in range(size): data = _convert_to_svm_node_array(x[i]) self.data.append(data); svmc.svm_node_matrix_set(x_matrix,i,data) self.maxlen = max(self.maxlen,len(x[i])) svmc.svm_problem_l_set(prob,size) svmc.svm_problem_y_set(prob,y_array) svmc.svm_problem_x_set(prob,x_matrix)