Returns the false positive rate for a given label

@param classLabel the label
@param edgeCase   What to output in case of 0/0
@return fpr as a double
331957
public double falsePositiveRate(int classLabel, double edgeCase) {
        double fpCount = falsePositives.getCount(classLabel);
        double tnCount = trueNegatives.getCount(classLabel);

        return EvaluationUtils.falsePositiveRate((long) fpCount, (long) tnCount, edgeCase);
    }
113626
public static String pkgNameOfClassName(String fqClassName) {
        int i = fqClassName.lastIndexOf('.');
        String pkg = i == -1 ? "" : fqClassName.substring(0, i);
        return ":" + pkg;
    }
1253914
private double getPrior(int classIndex) {
		// Maximum likelihood
		Double currentCount = this.classInstances.get(classIndex);
		if (currentCount == null || currentCount == 0)
			return 0;
		else
			return currentCount * 1. / this.instancesSeen;
	}
1047387
@Override
    public double getLearningRate(int iterCount, int i) {
        // We use the learning rate suggested in Leon Bottou's (2012) SGD Tricks paper.
        // 
        // \gamma_t = \frac{\gamma_0}{(1 + \gamma_0 \lambda t)^p}
        //
        // For SGD p = 1.0, for ASGD p = 0.75
        if (prm.power == 1.0) {
            return prm.initialLr / (1 + prm.initialLr * prm.lambda * iterCount);
        } else {
            return prm.initialLr / Math.pow(1 + prm.initialLr * prm.lambda * iterCount, prm.power);
        }
    }
49592
protected boolean isGetClassOnTypeLiteral() {
		JvmIdentifiableElement feature = getFeature();
		if (isGetClass(feature)) {
			XExpression receiver = getSyntacticReceiver();
			if (receiver instanceof XAbstractFeatureCall) {
				IFeatureLinkingCandidate linkingCandidate = getState().getResolvedTypes().getLinkingCandidate((XAbstractFeatureCall) receiver);
				if (linkingCandidate != null && linkingCandidate.isTypeLiteral()) {
					return true;
				}
			}
		}
		return false;
	}
536079
def _getTrafficClassAndFlowLabel(self):
        
        if self.tf == 0x0:
            return (self.tc_ecn << 6) + self.tc_dscp, self.flowlabel
        elif self.tf == 0x1:
            return (self.tc_ecn << 6), self.flowlabel
        elif self.tf == 0x2:
            return (self.tc_ecn << 6) + self.tc_dscp, 0
        else:
            return 0, 0
463349
private void primitive2b(MethodVisitor mv, ClassNode type) {
        Label trueLabel = new Label();
        Label falseLabel = new Label();
        // for the various types we make first a 
        // kind of conversion to int using a compare
        // operation and then handle the result common
        // for all cases. In case of long that is LCMP,
        // for int nothing is to be done
        if (type==ClassHelper.double_TYPE) {
            mv.visitInsn(DCONST_0);
            mv.visitInsn(DCMPL);
        } else if (type==ClassHelper.long_TYPE) {
            mv.visitInsn(LCONST_0);
            mv.visitInsn(LCMP);
        } else if (type==ClassHelper.float_TYPE) {
            mv.visitInsn(FCONST_0);
            mv.visitInsn(FCMPL);
        } else if (type==ClassHelper.int_TYPE) {
            // nothing, see comment above
        }
        mv.visitJumpInsn(IFEQ, falseLabel);
        mv.visitInsn(ICONST_1);
        mv.visitJumpInsn(GOTO, trueLabel);
        mv.visitLabel(falseLabel);
        mv.visitInsn(ICONST_0);
        mv.visitLabel(trueLabel);
        // other cases can be used directly
    }
53527
public double fBeta(double beta, EvaluationAveraging averaging) {
        if(getNumRowCounter() == 0.0){
            return Double.NaN;  //No data
        }
        int nClasses = confusion().getClasses().size();

        if (nClasses == 2) {
            return EvaluationUtils.fBeta(beta, (long) truePositives.getCount(1), (long) falsePositives.getCount(1),
                            (long) falseNegatives.getCount(1));
        }

        if (averaging == EvaluationAveraging.Macro) {
            double macroFBeta = 0.0;
            int count = 0;
            for (int i = 0; i < nClasses; i++) {
                double thisFBeta = fBeta(beta, i, -1);
                if (thisFBeta != -1) {
                    macroFBeta += thisFBeta;
                    count++;
                }
            }
            macroFBeta /= count;
            return macroFBeta;
        } else if (averaging == EvaluationAveraging.Micro) {
            long tpCount = 0;
            long fpCount = 0;
            long fnCount = 0;
            for (int i = 0; i < nClasses; i++) {
                tpCount += truePositives.getCount(i);
                fpCount += falsePositives.getCount(i);
                fnCount += falseNegatives.getCount(i);
            }
            return EvaluationUtils.fBeta(beta, tpCount, fpCount, fnCount);
        } else {
            throw new UnsupportedOperationException("Unknown averaging approach: " + averaging);
        }
    }
99796
public String eval(AbstractClassifier cl) {
		TPredict[] res = cl.classify(test,1);
		int[] pred = new int[res.length];
		for(int i=0;i<res.length;i++){
			pred[i] = (Integer) res[i].getLabel(0); //Get the first Label
		}
		float Accuracy;
		float MarcoF;
		float MacroPrecision = 0;
		float MacroRecall = 0;
		float Treeloss;


		float leafcor=0;
		float loss=0;
		float[] ttcon=new float[10];

		float[] truePositive=new float[numofclass];
		float[] falseNegative=new float[numofclass];
		float[] numberclass =new float[numofclass];
		float[] falsePositive=new float[numofclass];

		for(int i=0;i<totnum;i++){

			if(golden[i]==pred[i]){//正确
				leafcor++;
				truePositive[golden[i]]++;

			}
			else{	
				falsePositive[pred[i]]++;
				falseNegative[golden[i]]++;
				if(tree!=null){
					loss+=tree.dist(golden[i], pred[i]);
				}

			}
		}
        for (int i = 0; i < totnum; i++) { 
            if (golden[i] < numofclass)
                numberclass[golden[i]]++;
            else
                System.out.println("Not Format");
        }
		Treeloss=loss/totnum;
		Accuracy=leafcor/totnum;

		System.out.println(" Accuracy:" + Accuracy);

		float count1=0;
		float count2=0;
		float[] precision = new float[numofclass];
		float[] recall = new float[numofclass];
		float[] f = new float[numofclass];


		for(int i=0;i<numofclass;i++){
			float base = truePositive[i]+falsePositive[i]; 

			if(base>0)
				precision[i]= truePositive[i]/base;
			else{
				count1++;	
			}
			base = truePositive[i]+falseNegative[i]; 
			if(base>0)
				recall[i] = truePositive[i]/base;
			else{
				count2++;
			}

			f[i] = 2*precision[i]*recall[i]/(precision[i]+recall[i]+Float.MIN_VALUE);
		}


		//计算宏平均
		MacroPrecision= MyArrays.sum(precision)/(numofclass-count1);
		MacroRecall=MyArrays.sum(recall)/(numofclass-count2);	

		MarcoF=2*MacroPrecision*MacroRecall/(MacroPrecision+MacroRecall+Float.MIN_VALUE);		

		StringBuilder sb= new StringBuilder();


		sb.append("===========评测结果===========\n");
		sb.append("--------------------微平均---------------------");
		sb.append("\n");
		sb.append("Accuracy:" + Accuracy);
		sb.append("\n");
		sb.append("--------------------宏平均---------------------\n");
		sb.append("Accuracy\t\tPrecision\t\tRecall \t\tF1");
		sb.append("\n");
		sb.append(df.format(Accuracy*100)+"\t\t"+ df.format(MacroPrecision*100)+"\t\t"+ df.format(MacroRecall*100) + "\t\t"
				+ df.format(MarcoF*100)+"\t\t"+ df.format(Treeloss));
		sb.append("\n");		
		sb.append("各类分析：");
		sb.append("\n");
		sb.append("Class\t\tNumberClass\t\tPrecision\t\tRecall \t\tF1");
		sb.append("\n");
		for(int i=0;i<numofclass;i++){
			sb.append(labels.lookupString(i)+"\t\t"+ (int)numberclass[i] + "\t\t" + df.format(precision[i]*100)+"\t\t"+ df.format(recall[i]*100)+"\t\t"+ df.format(f[i]*100));
			sb.append("\n");
		}



		int i=0;
		while(ttcon[i]!=0){
			ttcon[i] = Float.parseFloat(df.format(ttcon[i]*100));
			sb.append(""+i+"th level accurary: "+(float)ttcon[i]/totnum);
			i++;
		}
		sb.append("===========评测结果 END===========");
		return sb.toString();
	}
1360396
private static int getClassWeight(Element e) {
        int weight = 0;

        /* Look for a special classname */
        String className = e.className();
        if (!isEmpty(className)) {
            Matcher negativeMatcher = Patterns.get(Patterns.RegEx.NEGATIVE)
                    .matcher(className);
            Matcher positiveMatcher = Patterns.get(Patterns.RegEx.POSITIVE)
                    .matcher(className);
            if (negativeMatcher.find()) {
                weight -= 25;
            }
            if (positiveMatcher.find()) {
                weight += 25;
            }
        }

        /* Look for a special ID */
        String id = e.id();
        if (!isEmpty(id)) {
            Matcher negativeMatcher = Patterns.get(Patterns.RegEx.NEGATIVE)
                    .matcher(id);
            Matcher positiveMatcher = Patterns.get(Patterns.RegEx.POSITIVE)
                    .matcher(id);
            if (negativeMatcher.find()) {
                weight -= 25;
            }
            if (positiveMatcher.find()) {
                weight += 25;
            }
        }

        return weight;
    }
1054642
public Map<String, Double> getFMeasureForLabels()
    {
        Map<String, Double> fMeasure = new LinkedHashMap<>();

        Map<String, Double> precisionForLabels = getPrecisionForLabels();
        Map<String, Double> recallForLabels = getRecallForLabels();

        for (String label : allGoldLabels) {
            double p = precisionForLabels.get(label);
            double r = recallForLabels.get(label);

            double fm = 0;

            if ((p + r) > 0) {
                fm = (2 * p * r) / (p + r);
            }

            fMeasure.put(label, fm);
        }

        return fMeasure;
    }
984400
public static double pdf(double val, double rate) {
    return .5 * rate * FastMath.exp(-rate * Math.abs(val));
  }
293652
public double getTagSequenceProb() {
    // System.err.println("Parse.getTagSequenceProb: "+type+" "+this);
    if (this.parts.size() == 1
        && this.parts.get(0).type.equals(ShiftReduceParser.TOK_NODE)) {
      // System.err.println(this+" "+prob);
      return Math.log(this.prob);
    } else if (this.parts.size() == 0) {
      System.err.println("Parse.getTagSequenceProb: Wrong base case!");
      return 0.0;
    } else {
      double sum = 0.0;
      for (final Parse parse : this.parts) {
        sum += parse.getTagSequenceProb();
      }
      return sum;
    }
  }
423713
@Deprecated
  public double scoreOf(RVFDatum<L, F> example, L label) {
    int iLabel = labelIndex.indexOf(label);
    double score = 0.0;
    Counter<F> features = example.asFeaturesCounter();
    for (F f : features.keySet()) {
      score += weight(f, iLabel) * features.getCount(f);
    }
    return score + thresholds[iLabel];
  }
710654
public double calcTurnWeight(int edgeFrom, int nodeVia, int edgeTo) {
        long turnFlags = turnCostExt.getTurnCostFlags(edgeFrom, nodeVia, edgeTo);
        if (turnCostEncoder.isTurnRestricted(turnFlags))
            return Double.POSITIVE_INFINITY;

        return turnCostEncoder.getTurnCost(turnFlags);
    }
144315
private static double[] transformToLabelProjection(
            final MathTransform toLabelProjection,
            final Coordinate borderIntersection) {
        try {
            double[] labelProj = new double[2];
            toLabelProjection
                    .transform(new double[]{borderIntersection.x, borderIntersection.y}, 0, labelProj, 0, 1);
            return labelProj;
        } catch (TransformException e) {
            throw new RuntimeException(e);
        }
    }
830711
public String getLabel(final String caption, final boolean captizliseFirstLetter) {
		if (captizliseFirstLetter) {
			return JKFormatUtil.capitalizeFirstLetters(getLabel(caption));
		} else {
			return getLabel(caption);
		}
	}