def model_training(n, i): meth = method[i] y, x = liblinearutil.svm_read_problem("other_method/kmeans_linear/%s/train_%s" % ( name, meth)) y_test, x_test = liblinearutil.svm_read_problem("other_method/kmeans_linear/%s/test_%s" % ( name, meth)) prob = liblinearutil.problem(y, x) temp_result = np.empty((14)) for idx, val in enumerate(cost): param = liblinearutil.parameter(' -q -c %f' % (val)) m = liblinearutil.train(prob, param) pred_labels, (temp_result[idx], MSE, SCC), pred_values = liblinearutil.predict(y_test, x_test, m) return (i, f_idx, n, temp_result)
def model_training(): meth = method[0] y, x = liblinearutil.svm_read_problem("other_method/kmeans_linear/%s/train_%s" % ( name, meth)) y_test, x_test = liblinearutil.svm_read_problem("other_method/kmeans_linear/%s/test_%s" % ( name, meth)) prob = liblinearutil.problem(y, x) temp_result = np.zeros((12)) # print(x.shape(1)) for idx, val in enumerate(cost): start = time.time() param = liblinearutil.parameter(' -q -c %f' % (val)) m = liblinearutil.train(prob, param) pred_labels, (temp_result[idx], MSE, SCC), pred_values = liblinearutil.predict(y_test, x_test, m) # print(temp_result) t2 = time.time()-start return np.max(temp_result),t2
def model_training(n, i): meth = method[i] y, x = liblinearutil.svm_read_problem( "other_method/kmeans_linear/%s/original_%s" % (name, meth)) prob = liblinearutil.problem(y, x) temp_result = np.empty((13)) for idx, val in enumerate(cost): param = liblinearutil.parameter('-v 5 -q -c %f' % (val)) temp_result[idx] = liblinearutil.train(prob, param) return (i, f_idx, n, temp_result)