private void setWeights(svm_parameter svmParam) { if (weights != null) { svmParam.nr_weight = weights.size(); svmParam.weight_label = new int[weights.size()]; svmParam.weight = new double[weights.size()]; for (int i = 0; i < weights.size(); ++i) { svmParam.weight_label[i] = i; svmParam.weight[i] = weights.get(i); } logger.debug("Class weights: " + weights); } }
public svm_parameter getDefaultSvmParameters() { svm_parameter param = new svm_parameter(); // default values param.svm_type = svm_parameter.C_SVC; param.kernel_type = svm_parameter.RBF; param.degree = 3; param.gamma = 0; // 1/num_features param.coef0 = 0; param.nu = 0.5; param.cache_size = 100; param.C = 1; param.eps = 1e-3; param.p = 0.1; param.shrinking = 1; param.probability = 0; param.nr_weight = 0; param.weight_label = new int[0]; param.weight = new double[0]; return param; }