当前位置: 首页>>代码示例>>Java>>正文


Java StatFunctions类代码示例

本文整理汇总了Java中cc.mallet.util.StatFunctions的典型用法代码示例。如果您正苦于以下问题:Java StatFunctions类的具体用法?Java StatFunctions怎么用?Java StatFunctions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StatFunctions类属于cc.mallet.util包,在下文中一共展示了StatFunctions类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: pValues

import cc.mallet.util.StatFunctions; //导入依赖的package包/类
public double[] pValues() {
	double[] values = new double[dimension];
	for (int index=0; index < dimension; index++) {
		double standardError = Math.sqrt(meanSquaredError *
										 xTransposeXInverse[(dimension * index) + index]);
		values[index] = 2 * (1.0 - StatFunctions.pt(Math.abs(parameters[index] / standardError),
													degreesOfFreedom));
	}
	
	return values;
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:12,代码来源:LeastSquares.java

示例2: printSummary

import cc.mallet.util.StatFunctions; //导入依赖的package包/类
/** Print a summary of the regression, similar to summary(lm(...)) in R */
public void printSummary() {
	double standardError, tPercentile;

	System.out.println("\tparam\tStd.Err\tt value\tPr(>|t|)");
	System.out.print("(Int)\t");
	System.out.print(formatter.format(parameters[interceptIndex]) + "\t");

	standardError = 
		Math.sqrt(meanSquaredError *
				  xTransposeXInverse[(dimension * interceptIndex) + interceptIndex]);

	System.out.print(formatter.format(standardError) + "\t");
	System.out.print(formatter.format(parameters[interceptIndex] / standardError) + "\t");

	tPercentile = 
		2 * (1.0 - StatFunctions.pt(Math.abs(parameters[interceptIndex] / standardError),
									degreesOfFreedom));

	System.out.println(formatter.format(tPercentile) + " " +
					   significanceStars(tPercentile));

	for (int index=0; index < dimension - 1; index++) {
		System.out.print(trainingData.getDataAlphabet().lookupObject(index) + "\t");
		System.out.print(formatter.format(parameters[index]) + "\t");
		
		standardError = 
			Math.sqrt(meanSquaredError *
					  xTransposeXInverse[(dimension * index) + index]);
		
		System.out.print(formatter.format(standardError) + "\t");
		System.out.print(formatter.format(parameters[index] / standardError) + "\t");

		tPercentile = 
			2 * (1.0 - StatFunctions.pt(Math.abs(parameters[index] / standardError),
										degreesOfFreedom));
		
		System.out.println(formatter.format(tPercentile) + " " +
						   significanceStars(tPercentile));
	}

	System.out.println();

	System.out.println("SSE: " + formatter.format(sumSquaredError) +
					   " DF: " + degreesOfFreedom);
	System.out.println("R^2: " + 
					   formatter.format(sumSquaredModel / (sumSquaredError + sumSquaredModel)));
	
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:50,代码来源:LeastSquares.java

示例3: calculateWeights

import cc.mallet.util.StatFunctions; //导入依赖的package包/类
/**
 * Calculates feature weights for features in the given instance list.
 */
private static double[] calculateWeights(InstanceList instanceList) {
  int numFeatures = instanceList.getAlphabet().size();
  double[] weights = new double[numFeatures];
  double[] truePositives = new double[numFeatures];
  double[] falsePositives = new double[numFeatures];
  double numPos = 0;
  double numNeg = 0;
  Label posLabel = null;
  for (Instance instance : instanceList) {
    if (posLabel == null)
      posLabel = (Label) instance.getTarget();
    boolean isPos = false;
    if (posLabel.equals(instance.getTarget())) {
      isPos = true;
      numPos++;
    } else {
      numNeg++;
    }
    FeatureVector fv = (FeatureVector) instance.getData();
    for (int index : fv.getIndices()) {
      if (isPos)
        truePositives[index]++;
      else
        falsePositives[index]++;
    }
  }
  for (int i = 0; i < numFeatures; i++) {
    double tpr = 0.5;
    if (numPos > 0) {
      tpr = Math.max(Math.min(BNS_MAX_RATE, truePositives[i] / numPos), BNS_MIN_RATE);
    }
    double fpr = 0.5;
    if (numNeg > 0) {
      fpr = Math.max(Math.min(BNS_MAX_RATE, falsePositives[i] / numNeg), BNS_MIN_RATE);
    }
    weights[i] =
        Math.abs(StatFunctions.qnorm(tpr, false) - StatFunctions.qnorm(fpr, false));
  }
  return weights;
}
 
开发者ID:mimno,项目名称:Mallet,代码行数:44,代码来源:BiNormalSeparation.java


注:本文中的cc.mallet.util.StatFunctions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。