libsvm.svm.svm_predict_values()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(221)

本文整理了Java中libsvm.svm.svm_predict_values()方法的一些代码示例,展示了svm.svm_predict_values()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。svm.svm_predict_values()方法的具体详情如下:
包路径:libsvm.svm
类名称:svm
方法名:svm_predict_values

svm.svm_predict_values介绍

暂无

代码示例

代码示例来源:origin: tw.edu.ntu.csie/libsvm

public static double svm_predict(svm_model model, svm_node[] x)
{
  int nr_class = model.nr_class;
  double[] dec_values;
  if(model.param.svm_type == svm_parameter.ONE_CLASS ||
      model.param.svm_type == svm_parameter.EPSILON_SVR ||
      model.param.svm_type == svm_parameter.NU_SVR)
    dec_values = new double[1];
  else
    dec_values = new double[nr_class*(nr_class-1)/2];
  double pred_result = svm_predict_values(model, x, dec_values);
  return pred_result;
}

代码示例来源:origin: com.facebook.thirdparty/libsvm

public static double svm_predict(svm_model model, svm_node[] x)
{
  int nr_class = model.nr_class;
  double[] dec_values;
  if(model.param.svm_type == svm_parameter.ONE_CLASS ||
      model.param.svm_type == svm_parameter.EPSILON_SVR ||
      model.param.svm_type == svm_parameter.NU_SVR)
    dec_values = new double[1];
  else
    dec_values = new double[nr_class*(nr_class-1)/2];
  double pred_result = svm_predict_values(model, x, dec_values);
  return pred_result;
}

代码示例来源:origin: jzy3d/jzy3d-api

public static double svm_predict(svm_model model, svm_node[] x)
{
  int nr_class = model.nr_class;
  double[] dec_values;
  if(model.param.svm_type == svm_parameter.ONE_CLASS ||
      model.param.svm_type == svm_parameter.EPSILON_SVR ||
      model.param.svm_type == svm_parameter.NU_SVR)
    dec_values = new double[1];
  else
    dec_values = new double[nr_class*(nr_class-1)/2];
  double pred_result = svm_predict_values(model, x, dec_values);
  return pred_result;
}

代码示例来源:origin: com.facebook.thirdparty/libsvm

public static double svm_predict_probability(svm_model model, svm_node[] x, double[] prob_estimates)
{
  if ((model.param.svm_type == svm_parameter.C_SVC || model.param.svm_type == svm_parameter.NU_SVC) &&
    model.probA!=null && model.probB!=null)
  {
    int i;
    int nr_class = model.nr_class;
    double[] dec_values = new double[nr_class*(nr_class-1)/2];
    svm_predict_values(model, x, dec_values);
    double min_prob=1e-7;
    double[][] pairwise_prob=new double[nr_class][nr_class];
    
    int k=0;
    for(i=0;i<nr_class;i++)
      for(int j=i+1;j<nr_class;j++)
      {
        pairwise_prob[i][j]=Math.min(Math.max(sigmoid_predict(dec_values[k],model.probA[k],model.probB[k]),min_prob),1-min_prob);
        pairwise_prob[j][i]=1-pairwise_prob[i][j];
        k++;
      }
    multiclass_probability(nr_class,pairwise_prob,prob_estimates);
    int prob_max_idx = 0;
    for(i=1;i<nr_class;i++)
      if(prob_estimates[i] > prob_estimates[prob_max_idx])
        prob_max_idx = i;
    return model.label[prob_max_idx];
  }
  else 
    return svm_predict(model, x);
}

代码示例来源:origin: jzy3d/jzy3d-api

public static double svm_predict_probability(svm_model model, svm_node[] x, double[] prob_estimates)
{
  if ((model.param.svm_type == svm_parameter.C_SVC || model.param.svm_type == svm_parameter.NU_SVC) &&
    model.probA!=null && model.probB!=null)
  {
    int i;
    int nr_class = model.nr_class;
    double[] dec_values = new double[nr_class*(nr_class-1)/2];
    svm_predict_values(model, x, dec_values);
    double min_prob=1e-7;
    double[][] pairwise_prob=new double[nr_class][nr_class];
    
    int k=0;
    for(i=0;i<nr_class;i++)
      for(int j=i+1;j<nr_class;j++)
      {
        pairwise_prob[i][j]=Math.min(Math.max(sigmoid_predict(dec_values[k],model.probA[k],model.probB[k]),min_prob),1-min_prob);
        pairwise_prob[j][i]=1-pairwise_prob[i][j];
        k++;
      }
    multiclass_probability(nr_class,pairwise_prob,prob_estimates);
    int prob_max_idx = 0;
    for(i=1;i<nr_class;i++)
      if(prob_estimates[i] > prob_estimates[prob_max_idx])
        prob_max_idx = i;
    return model.label[prob_max_idx];
  }
  else 
    return svm_predict(model, x);
}

代码示例来源:origin: tw.edu.ntu.csie/libsvm

int nr_class = model.nr_class;
double[] dec_values = new double[nr_class*(nr_class-1)/2];
svm_predict_values(model, x, dec_values);

代码示例来源:origin: com.facebook.thirdparty/libsvm

svm_predict_values(submodel,prob.x[perm[j]],dec_value);
dec_values[perm[j]]=dec_value[0];

代码示例来源:origin: tw.edu.ntu.csie/libsvm

svm_predict_values(submodel,prob.x[perm[j]],dec_value);
dec_values[perm[j]]=dec_value[0];

代码示例来源:origin: jzy3d/jzy3d-api

svm_predict_values(submodel,prob.x[perm[j]],dec_value);
dec_values[perm[j]]=dec_value[0];

代码示例来源:origin: org.clulab/processors

final int nr_class = svm.svm_get_nr_class(model);
final double[] dec_values = new double[nr_class*(nr_class-1)/2];
svm.svm_predict_values(model, x, dec_values);

代码示例来源:origin: org.maltparser/maltparser

final int nr_class = svm.svm_get_nr_class(model);
final double[] dec_values = new double[nr_class*(nr_class-1)/2];
svm.svm_predict_values(model, x, dec_values);

代码示例来源:origin: jatecs/jatecs

public ClassificationResult classify(IIndex testIndex, int docID) {
  ClassificationResult res = new ClassificationResult();
  IIntIterator feats = testIndex.getContentDB().getDocumentFeatures(docID);
  svm_node[] doc = new svm_node[testIndex.getContentDB().getDocumentFeaturesCount(docID)];
  int i = 0;
  int featID = 0;
  while (feats.hasNext()) {
    featID = feats.next();
    svm_node node = new svm_node();
    node.index = featID + 1;
    node.value = testIndex.getWeightingDB().getDocumentFeatureWeight(docID, featID);
    doc[i++] = node;
  }
  res.documentID = docID;
  for (short catID = 0; catID < getCategoryCount(); catID++) {
    svm_model model = _models[catID];
    double[] values = new double[1];
    double prediction = svm.svm_predict_values(model, doc, values);
    res.categoryID.add(catID);
    // If the classifier is completely un-confident (i.e. it has no positive examples for this category in the training set)
    // the confidence value is set to the minimum negative value (negative confidence = negative decision)
    if (values[0] == 0) {
      prediction = -1;
      values[0] = -Double.MIN_VALUE;
    }
    res.score.add(prediction * Math.abs(values[0]));
  }
  return res;
}

代码示例来源:origin: jdmp/java-data-mining-package

svm.svm_predict_values(model, x, prediction);
Matrix output = Matrix.Factory.linkToValue(prediction[0]);
return output;

代码示例来源:origin: elki-project/elki

x[d].value = vec.doubleValue(d);
svm.svm_predict_values(model, x, buf);
double score = -buf[0]; // / param.gamma; // Heuristic rescaling, sorry.

相关文章