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

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

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

Utils.variance介绍

[英]Computes the variance for an array of doubles.
[中]计算双精度数组的方差。

代码示例

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

", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
" std. Erlang-5 dist:");
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
" std. Gamma(4.5) dist:");
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
" std. Gamma(0.5) dist:");
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
" std. Gaussian(5, 2) dist:");
  ", Variance is "+Utils.variance(varb)+"\n");

代码示例来源: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: Waikato/weka-trunk

", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
" std. Erlang-5 dist:");
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
" std. Gamma(4.5) dist:");
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
" std. Gamma(0.5) dist:");
  ", Variance is "+Utils.variance(varb)+
  "\n\nGenerate "+n+" values with"+
" std. Gaussian(5, 2) dist:");
  ", Variance is "+Utils.variance(varb)+"\n");

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

private void checkAccuracy(long var, long[] values, double tol) {
 double ref = Double.longBitsToDouble(var);
 double test = Utils.variance(convert(values));
 assertEquals("Inaccurate variance calculation!", ref, test, Math.abs(tol*ref));
}

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

private void checkAccuracy(long var, long[] values, double tol) {
 double ref = Double.longBitsToDouble(var);
 double test = Utils.variance(convert(values));
 assertEquals("Inaccurate variance calculation!", ref, test, Math.abs(tol*ref));
}

代码示例来源: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 stdDev = Math.sqrt(Utils.variance(correctStatistics));
double stdDevPrecision = Math.sqrt(Utils.variance(precisionStatistics));
double stdDevRecall = Math.sqrt(Utils.variance(recallStatistics));

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

+ Utils.correlation(doubles, doubles, doubles.length));
System.out.println("Mean: " + Utils.mean(doubles));
System.out.println("Variance: " + Utils.variance(doubles));
System.out.println("Sum (doubles): " + Utils.sum(doubles));
System.out.println("Sum (ints): " + Utils.sum(ints));

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

+ Utils.correlation(doubles, doubles, doubles.length));
System.out.println("Mean: " + Utils.mean(doubles));
System.out.println("Variance: " + Utils.variance(doubles));
System.out.println("Sum (doubles): " + Utils.sum(doubles));
System.out.println("Sum (ints): " + Utils.sum(ints));

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

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_SuffixMean, Utils.mean(values.toArray()));
if (!m_SkipStdDev)
  result.put(key + m_SuffixStdDev, Math.sqrt(Utils.variance(values.toArray())));

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

/**
 * Tests the accuracy and behavior of the {@link Utils.variance} method.
 */
public void testVariance() {
 
 assertTrue("Incorrect behaviour when count <= 1!",
   Double.isNaN(Utils.variance(new double[]{})));
 assertTrue("Incorrect behaviour when count <= 1!",
   Double.isNaN(Utils.variance(new double[]{3})));
 
 checkAccuracy(generatedVar1, generatedValues1);
 checkAccuracy(generatedVar2, generatedValues2, 1e-2);
 checkAccuracy(generatedVar3, generatedValues3);
 checkAccuracy(generatedVar4, generatedValues4);
 checkAccuracy(generatedVar5, generatedValues5);
 checkAccuracy(generatedVar6, generatedValues6, 2);
 checkAccuracy(generatedVar7, generatedValues7);
 checkAccuracy(generatedVar8, generatedValues8, 2);
 checkAccuracy(generatedVar9, generatedValues9);
 checkAccuracy(generatedVar10, generatedValues10);
}

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

/**
 * Tests the accuracy and behavior of the {@link Utils.variance} method.
 */
public void testVariance() {
 
 assertTrue("Incorrect behaviour when count <= 1!",
   Double.isNaN(Utils.variance(new double[]{})));
 assertTrue("Incorrect behaviour when count <= 1!",
   Double.isNaN(Utils.variance(new double[]{3})));
 
 checkAccuracy(generatedVar1, generatedValues1);
 checkAccuracy(generatedVar2, generatedValues2, 1e-2);
 checkAccuracy(generatedVar3, generatedValues3);
 checkAccuracy(generatedVar4, generatedValues4);
 checkAccuracy(generatedVar5, generatedValues5);
 checkAccuracy(generatedVar6, generatedValues6, 2);
 checkAccuracy(generatedVar7, generatedValues7);
 checkAccuracy(generatedVar8, generatedValues8, 2);
 checkAccuracy(generatedVar9, generatedValues9);
 checkAccuracy(generatedVar10, generatedValues10);
}

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

if (Utils.variance(numAttVals) == 0) {
 m_correlations[i] = 0;
  if (Utils.variance(numAttVals) == 0) {
   corr = 0;

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

if (Utils.variance(numAttVals) == 0) {
 m_correlations[i] = 0;
  if (Utils.variance(numAttVals) == 0) {
   corr = 0;

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

m_means[i] = m_trainInstances.meanOrMode(i);
m_stdDevs[i] =
 Math.sqrt(Utils.variance(m_trainInstances.attributeToDoubleArray(i)));

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

m_means[i] = m_trainInstances.meanOrMode(i);
m_stdDevs[i] =
 Math.sqrt(Utils.variance(m_trainInstances.attributeToDoubleArray(i)));

相关文章