接受的答案就像一個魅力。確保在訓練期間設置probability = 1
。
如果你想在信心沒有與門限符合下降的預測,這裏是代碼示例:
double confidenceScores[] = new double[model.nr_class];
svm.svm_predict_probability(model, svmVector, confidenceScores);
/*System.out.println("text="+ text);
for (int i = 0; i < model.nr_class; i++) {
System.out.println("i=" + i + ", labelNum:" + model.label[i] + ", name=" + classLoadMap.get(model.label[i]) + ", score="+confidenceScores[i]);
}*/
//finding max confidence;
int maxConfidenceIndex = 0;
double maxConfidence = confidenceScores[maxConfidenceIndex];
for (int i = 1; i < confidenceScores.length; i++) {
if(confidenceScores[i] > maxConfidence){
maxConfidenceIndex = i;
maxConfidence = confidenceScores[i];
}
}
double threshold = 0.3; // set this based data & no. of classes
int labelNum = model.label[maxConfidenceIndex];
// reverse map number to name
String targetClassLabel = classLoadMap.get(labelNum);
LOG.info("classNumber:{}, className:{}; confidence:{}; for text:{}",
labelNum, targetClassLabel, (maxConfidence), text);
if (maxConfidence < threshold) {
LOG.info("Not enough confidence; threshold={}", threshold);
targetClassLabel = null;
}
return targetClassLabel;
@dmcer哪個包具有較小的學習曲線(Java API的使用LIBSVM或jlibsvm包裝)?一般來說,我是SVM的新手。 – GobiasKoffi 2010-10-15 14:49:35
@rohanbk - 可能是jlibsvm,因爲它看起來和感覺就像一個典型的Java API。 – dmcer 2010-10-15 23:20:13
@dmcer您是否有使用WEKA進行SVM的經驗? – GobiasKoffi 2010-10-16 05:26:43