libsvm Java实现

libsvm Java实现,第1张

libsvm Java实现

在我看来,您的评估方法错误的。应该是这样的:

public double evaluate(double[] features, svm_model model) {    svm_node[] nodes = new svm_node[features.length-1];    for (int i = 1; i < features.length; i++)    {        svm_node node = new svm_node();        node.index = i;        node.value = features[i];        nodes[i-1] = node;    }    int totalClasses = 2;int[] labels = new int[totalClasses];    svm.svm_get_labels(model,labels);    double[] prob_estimates = new double[totalClasses];    double v = svm.svm_predict_probability(model, nodes, prob_estimates);    for (int i = 0; i < totalClasses; i++){        System.out.print("(" + labels[i] + ":" + prob_estimates[i] + ")");    }    System.out.println("(Actual:" + features[0] + " Prediction:" + v + ")");    return v;}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5507682.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-13
下一篇 2022-12-13

发表评论

登录后才能评论

评论列表(0条)

保存