标签:python libsvm svmpredict svmtrain -c
import numpy import os #os.chdir(‘C:\Program Files\libsvm-3.16\python’) os.chdir("F:\\wfpdm\\20150727_1010\\libsvm\\libsvm-3.12\\python") import sys sys.path.append('F:\\wfpdm\\20150727_1010\\libsvm\\libsvm-3.12\\python') from svmutil import * #y, x = svm_read_problem('../heart_scale') #m = svm_train(y[:200], x[:200], '-c 10 -t 0 -p 10') #p_label, p_acc, p_val = svm_predict(y[200:], x[200:], m) Data_Set = [] Data_Lab = [] for k in range(5): arr = numpy.random.random([30,45]) lab = [k]*30 for i in numpy.arange(0,30): j = i%3 arr[i,k*9+j*3:k*9+j*3+3] = arr[i,k*9+j*3:k*9+j*3+3]+100 print arr.shape Data_Set.append(arr) Data_Lab.append(lab) train = Data_Set[0].tolist() m = svm_train(Data_Lab[0], Data_Set[0].tolist(), '-c 10 -t 0 -p 10') p_label, p_acc, p_val = svm_predict(Data_Lab[0], Data_Set[0].tolist(), m)
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:python libsvm svmpredict svmtrain -c
原文地址:http://blog.csdn.net/u013630349/article/details/47323883