weka.core.Utils.mean()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(151)

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

Utils.mean介绍

[英]Computes the mean for an array of doubles.
[中]计算双精度数组的平均值。

代码示例

代码示例来源:origin: Waikato/weka-trunk

double eval(double[] args) {
 return Utils.mean(args);
}

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

double eval(double[] args) {
 return Utils.mean(args);
}

代码示例来源:origin: net.sf.meka/meka

/**
 * Combine Predictions - Combine together various results (for example, from cross-validation)
 * into one, simply by appending predictions and true values together, and averaging together their 'vals'.
 * @param folds    an array of Results
 * @return a combined Result
 */
public static Result combinePredictions(Result folds[]) { 
  Result r = new Result();
  // set info
  r.info = folds[0].info;
  // append all predictions and true values
  for(int f = 0; f < folds.length; f++) {
    r.predictions.addAll(folds[f].predictions);
    r.actuals.addAll(folds[f].actuals);
  }
  r.vals = folds[0].vals;
  // average all vals
  for(String metric : folds[0].vals.keySet()) {
    if (folds[0].vals.get(metric) instanceof Double) {
      double values[] = new double[folds.length];
      for(int i = 0; i < folds.length; i++) {
        values[i] = (Double)folds[i].vals.get(metric);
      }
      r.vals.put(metric,Utils.mean(values));
    }
  }
  return r;
}

代码示例来源:origin: Waikato/meka

/**
 * Combine Predictions - Combine together various results (for example, from cross-validation)
 * into one, simply by appending predictions and true values together, and averaging together their 'vals'.
 * @param folds    an array of Results
 * @return a combined Result
 */
public static Result combinePredictions(Result folds[]) { 
  Result r = new Result();
  // set info
  r.info = folds[0].info;
  // append all predictions and true values
  for(int f = 0; f < folds.length; f++) {
    r.predictions.addAll(folds[f].predictions);
    r.actuals.addAll(folds[f].actuals);
  }
  r.vals = folds[0].vals;
  // average all vals
  for(String metric : folds[0].vals.keySet()) {
    if (folds[0].vals.get(metric) instanceof Double) {
      double values[] = new double[folds.length];
      for(int i = 0; i < folds.length; i++) {
        values[i] = (Double)folds[i].vals.get(metric);
      }
      r.vals.put(metric,Utils.mean(values));
    }
  }
  return r;
}

代码示例来源:origin: net.sf.meka.thirdparty/mulan

public double getValue() {
  double[] labelAUC = new double[numOfLabels];
  for (int i = 0; i < numOfLabels; i++) {
    ThresholdCurve tc = new ThresholdCurve();
    Instances result = tc.getCurve(m_Predictions[i], 1);
    labelAUC[i] = ThresholdCurve.getROCArea(result);
  }
  return Utils.mean(labelAUC);
}

代码示例来源:origin: nz.ac.waikato.cms.weka/meka

/**
 * AverageResults - Create a Result with the average of an array of Results
 * @param    folds    array of Results (e.g., from CV-validation)
 * @return    A result reporting the average of these folds.
 */
public static Result averageResults(Result folds[]) { 
  Result r = new Result();
  // for info ..
  r.info = folds[0].info;
  // for output ..
  for(String metric : folds[0].output.keySet()) {
    double values[] = new double[folds.length];
    for(int i = 0; i < folds.length; i++) {
      values[i] = folds[i].output.get(metric);
    }
    String avg_sd = Utils.doubleToString(Utils.mean(values),5,3)+" +/- "+Utils.doubleToString(Math.sqrt(Utils.variance(values)),5,3);
    r.info.put(metric,avg_sd);
  }
  // and now for 'vals' ..
  for(String metric : folds[0].vals.keySet()) {
    double values[] = new double[folds.length];
    for(int i = 0; i < folds.length; i++) {
      values[i] = folds[i].vals.get(metric);
    }
    String avg_sd = Utils.doubleToString(Utils.mean(values),5,3)+" +/- "+Utils.doubleToString(Math.sqrt(Utils.variance(values)),5,3);
    r.info.put(metric,avg_sd);
  }
  r.setInfo("Type","CV");
  return r;
}

代码示例来源:origin: net.sf.meka.thirdparty/mulan

interpolatedPrecision[i] = highestPrecisionAfterPos(pos, precisions);
double averageInterpolatedPrecision = Utils.mean(interpolatedPrecision);

代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable

System.out.println("\nMean is "+Utils.mean(varb)+
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
System.out.println("\nMean is "+Utils.mean(varb)+
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
System.out.println("\nMean is "+Utils.mean(varb)+
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
System.out.println("\nMean is "+Utils.mean(varb)+
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
 System.out.print("["+i+"] "+varb[i]+", ");
System.out.println("\nMean is "+Utils.mean(varb)+
  ", Variance is "+Utils.variance(varb)+"\n");

代码示例来源:origin: com.entopix/maui

double avgConsistencyDocs = Utils.mean(consistencyDocs);
  log.info("Average consistency with indexer " + indexer.getName() + ": " + avgConsistencyDocs);
double avgConsistencyPeople = Utils.mean(consistencyPeople);
log.info("Average consistency overall: " + avgConsistencyPeople);

代码示例来源:origin: Waikato/weka-trunk

System.out.println("\nMean is "+Utils.mean(varb)+
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
System.out.println("\nMean is "+Utils.mean(varb)+
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
System.out.println("\nMean is "+Utils.mean(varb)+
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
System.out.println("\nMean is "+Utils.mean(varb)+
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
 System.out.print("["+i+"] "+varb[i]+", ");
System.out.println("\nMean is "+Utils.mean(varb)+
  ", Variance is "+Utils.variance(varb)+"\n");

代码示例来源:origin: Waikato/meka

bwriter.write(String.format("%12s ", "Avg.\\ Rank"));
for (i = 0; i < classifiers.size(); i++) {
  String value = String.format("& %5.3f      ", Utils.mean(A.toDoubleArray(MatrixUtils.getCol(ranks, i))));
  bwriter.write(value);

代码示例来源:origin: net.sf.meka/meka

bwriter.write(String.format("%12s ", "Avg.\\ Rank"));
for (i = 0; i < classifiers.size(); i++) {
  String value = String.format("& %5.3f      ", Utils.mean(A.toDoubleArray(MatrixUtils.getCol(ranks, i))));
  bwriter.write(value);

代码示例来源:origin: Waikato/meka

values[i] = (Double)folds[i].output.get(metric);
String avg_sd = Utils.doubleToString(Utils.mean(values),5,3)+" +/- "+Utils.doubleToString(Math.sqrt(Utils.variance(values)),5,3);
r.output.put(metric,avg_sd);
  values[i] = (Integer)folds[i].output.get(metric);
String avg_sd = Utils.doubleToString(Utils.mean(values),5,3)+" +/- "+Utils.doubleToString(Math.sqrt(Utils.variance(values)),5,3);
r.output.put(metric,avg_sd);
  values[i] = (Double)folds[i].vals.get(metric);
String avg_sd = Utils.doubleToString(Utils.mean(values),5,3)+" +/- "+Utils.doubleToString(Math.sqrt(Utils.variance(values)),5,3);
r.vals.put(metric,avg_sd);

代码示例来源:origin: net.sf.meka/meka

values[i] = (Double)folds[i].output.get(metric);
String avg_sd = Utils.doubleToString(Utils.mean(values),5,3)+" +/- "+Utils.doubleToString(Math.sqrt(Utils.variance(values)),5,3);
r.output.put(metric,avg_sd);
  values[i] = (Integer)folds[i].output.get(metric);
String avg_sd = Utils.doubleToString(Utils.mean(values),5,3)+" +/- "+Utils.doubleToString(Math.sqrt(Utils.variance(values)),5,3);
r.output.put(metric,avg_sd);
  values[i] = (Double)folds[i].vals.get(metric);
String avg_sd = Utils.doubleToString(Utils.mean(values),5,3)+" +/- "+Utils.doubleToString(Math.sqrt(Utils.variance(values)),5,3);
r.vals.put(metric,avg_sd);

代码示例来源:origin: com.entopix/maui

double avg = Utils.mean(correctStatistics);
double stdDev = Math.sqrt(Utils.variance(correctStatistics));
double avgPrecision = Utils.mean(precisionStatistics);
double stdDevPrecision = Math.sqrt(Utils.variance(precisionStatistics));
double avgRecall = Utils.mean(recallStatistics);
double stdDevRecall = Math.sqrt(Utils.variance(recallStatistics));

代码示例来源:origin: net.sf.meka/meka

result.put(key + m_SuffixCount, values.size());
if (!m_SkipMean)
  result.put(key + m_SuffixMean, Utils.mean(values.toArray()));
if (!m_SkipStdDev)
  result.put(key + m_SuffixStdDev, Math.sqrt(Utils.variance(values.toArray())));

代码示例来源:origin: Waikato/meka

result.put(key + m_SuffixCount, values.size());
if (!m_SkipMean)
  result.put(key + m_SuffixMean, Utils.mean(values.toArray()));
if (!m_SkipStdDev)
  result.put(key + m_SuffixStdDev, Math.sqrt(Utils.variance(values.toArray())));

代码示例来源:origin: net.sf.meka.thirdparty/mulan

protected void buildInternal(MultiLabelInstances trainingData) throws Exception {
  baseLearner.build(trainingData);
  if (folds == 0) {
    threshold = computeThreshold(baseLearner, trainingData, measure);
  } else {
    LabelsMetaData labelsMetaData = trainingData.getLabelsMetaData();
    double[] thresholds = new double[folds];
    for (int f = 0; f < folds; f++) {
      Instances train = trainingData.getDataSet().trainCV(folds, f);
      MultiLabelInstances trainMulti = new MultiLabelInstances(train, labelsMetaData);
      Instances test = trainingData.getDataSet().testCV(folds, f);
      MultiLabelInstances testMulti = new MultiLabelInstances(test, labelsMetaData);
      MultiLabelLearner tempLearner = foldLearner.makeCopy();
      tempLearner.build(trainMulti);
      thresholds[f] = computeThreshold(tempLearner, testMulti, measure);
    }
    threshold = Utils.mean(thresholds);
  }
}

代码示例来源:origin: Waikato/meka

return Utils.mean(AUC);

代码示例来源:origin: net.sf.meka/meka

return Utils.mean(AUC);

相关文章