Similar to histogram but exact values of the weights
to see whether there are many equal weights.

@return A human readable string about the classifier distribution.
161194
public String toDistributionString(int treshold) {
    Counter<Double> weightCounts = new ClassicCounter<Double>();
    StringBuilder s = new StringBuilder();
    s.append("Total number of weights: ").append(totalSize());
    for (int f = 0; f < weights.length; f++) {
      for (int l = 0; l < weights[f].length; l++) {
        weightCounts.incrementCount(weights[f][l]);
      }
    }

    s.append("Counts of weights\n");
    Set<Double> keys = Counters.keysAbove(weightCounts, treshold);
    s.append(keys.size()).append(" keys occur more than ").append(treshold).append(" times ");
    return s.toString();
  }
305920
public String asString()
    {
        TreeMap<Tag, Value> orderedAttributes = new TreeMap<Tag, Value>(attributes);
        StringBuilder result = new StringBuilder();
        for (Iterator<Map.Entry<Tag, Value>> entries = orderedAttributes.entrySet().iterator(); entries.hasNext(); )
        {
            Map.Entry<Tag, Value> mapEntry = entries.next();
            Tag tag = mapEntry.getKey();
            Value value = mapEntry.getValue();
            if (value.isPresenceType())
            {
                result.append(tag.tag);
            }
            else
            {
                result.append("(").append(tag.tag).append("=");
                if (value.multiValued)
                {
                    Object[] values = value.getValues();
                    for (int i = 0; i < values.length; ++i)
                    {
                        if (i > 0) result.append(",");
                        if (value.isOpaqueType())
                            result.append(bytesToOpaque((byte[])values[i]));
                        else
                            result.append(escapeValue(String.valueOf(values[i])));
                    }
                }
                else
                {
                    if (value.isOpaqueType())
                        result.append(bytesToOpaque((byte[])value.getValue()));
                    else
                        result.append(escapeValue(String.valueOf(value.getValue())));
                }
                result.append(")");
            }
            if (entries.hasNext()) result.append(",");
        }
        return result.toString();
    }
763216
private String getStatsString() {
    SplitTypeStats allTypeStats = splitTypeStatsMap.get(SplitType.ALL);
    Map<String, Map<String, Number>> statsMapMap =
      new HashMap<String, Map<String, Number>>();
    for (Map.Entry<SplitType, SplitTypeStats> entry :
        splitTypeStatsMap.entrySet()) {
      Map<String, Number> statsMap = new HashMap<String, Number>();
      statsMapMap.put(entry.getKey().toString(), statsMap);

      float percentTotalSplitCount =
        (100f * entry.getValue().getTotalSplitCount()) /
        allTypeStats.getTotalSplitCount();
      float percentTotalSize =
        (100f * entry.getValue().getTotalSize()) /
        allTypeStats.getTotalSize();
      float percentTotalBlockCount =
          (100f * entry.getValue().getTotalBlockCount()) /
          allTypeStats.getTotalBlockCount();
      float averageSizePerSplit =
          ((float) entry.getValue().getTotalSize()) /
          entry.getValue().getTotalSplitCount();
      float averageHostCountPerSplit =
         ((float) entry.getValue().getTotalHostCount()) /
         entry.getValue().getTotalSplitCount();
      float averageBlockCountPerSplit =
          ((float) entry.getValue().getTotalBlockCount()) /
          entry.getValue().getTotalSplitCount();
      statsMap.put("totalSplitCount", entry.getValue().getTotalSplitCount());
      statsMap.put("percentTotalSplitCount", percentTotalSplitCount);
      statsMap.put("totalSize", entry.getValue().getTotalSize());
      statsMap.put("percentTotalSize", percentTotalSize);
      statsMap.put("averageSizePerSplit", averageSizePerSplit);
      statsMap.put("totalHostCount", entry.getValue().getTotalHostCount());
      statsMap.put("averageHostCountPerSplit", averageHostCountPerSplit);
      statsMap.put("totalBlockCount", entry.getValue().getTotalBlockCount());
      statsMap.put("percentTotalBlockCount", percentTotalBlockCount);
      statsMap.put("averageBlockCountPerSplit", averageBlockCountPerSplit);
    }
    return JSON.toString(statsMapMap);
  }
119795
public String getDiscriminator()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
    {
      SibTr.entry(tc, "getDiscriminator");
      SibTr.exit(tc, "getDiscriminator", discriminator);
    }
    return discriminator;
  }
49166
protected ArrayList<Integer> getMAXIndexes(){
    	
    	ArrayList<Integer> maxWIndex=new ArrayList<Integer>();
    	Pair[] newEnsembleWeights = new Pair[getNbActiveClassifiers()];  	
    	System.arraycopy(ensembleWeights, 0, newEnsembleWeights, 0, newEnsembleWeights.length);
    	
    	Arrays.sort(newEnsembleWeights);
    	
    	double maxWVal = newEnsembleWeights[newEnsembleWeights.length-1].val;
    		
    	for (int i = newEnsembleWeights.length-1 ; i>=0 ; i--){
    		if (newEnsembleWeights[i].val!=maxWVal)
    			break;
    		else
    			maxWIndex.add(newEnsembleWeights[i].index);
    		
    	}
    	return maxWIndex;
    }
1308328
public String getDataset() {
    if (isReference()) {
      final LibrarySet master = (LibrarySet) getCheckedRef(LibrarySet.class, "LibrarySet");
      return master.getDataset();
    }
    return this.dataset;
  }
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();
	}
862998
public LoadStatistics getLoadStatistics() throws IOException {
        // TODO: Think about the following handling, cause that has also being
        // done in Computer#details().
        String name;
        if ("master".equals(displayName)) {
            name = "(master)";
        } else {
            name = EncodingUtils.encode(displayName);
        }

        // TODO: ?depth=2 good idea or could this being done better?
        return client.get("/computer/" + name + "/" + "loadStatistics/?depth=2", LoadStatistics.class);
    }
1244657
public AttributeVector summary() {
        Attribute attr = new NumericAttribute(attribute.getName() + " Summary");
        String[] names = {"min", "q1", "median", "mean", "q3", "max"};

        double[] stat = new double[6];
        stat[0] = Math.min(vector);
        stat[1] = Math.q1(vector);
        stat[2] = Math.median(vector);
        stat[3] = Math.mean(vector);
        stat[4] = Math.q3(vector);
        stat[5] = Math.max(vector);

        return new AttributeVector(attr, stat, names);
    }
384605
public String getDescriptorExpression() {
    // We only need to import the outermost descriptor.
    Descriptor descriptor = typeDescriptor;
    while (descriptor.getContainingType() != null) {
      descriptor = descriptor.getContainingType();
    }
    return JavaQualifiedNames.getQualifiedName(descriptor) + ".getDescriptor()";
  }
860024
def normalized(self):
        
        total = self.total()
        result = Histogram()
        for value, count in iteritems(self):
            try:
                result[value] = count / float(total)
            except UnorderableElements as e:
                result = Histogram.from_dict(dict(result), key=hash)
                result[value] = count / float(total)
        return result
689709
private int getPoorestClassifierIndex() {
		int minIndex = 0;
		
		for (int i = 1; i < this.weights.length; i++) {
			if(this.weights[i][0] < this.weights[minIndex][0]){
				minIndex = i;
			}
		}
		
		return minIndex;
	}
821236
public String explainScore(StringWrapper s, StringWrapper t) {
        BagOfTokens sBag = (BagOfTokens) s;
        BagOfTokens tBag = (BagOfTokens) t;
        StringBuilder buf = new StringBuilder("");
        PrintfFormat fmt = new PrintfFormat("%.3f");
        buf.append("Common tokens: ");
        for (Iterator<Token> i = sBag.tokenIterator(); i.hasNext();) {
            Token tok = i.next();
            if (tBag.contains(tok)) {
                buf.append(" " + tok.getValue() + ": ");
                buf.append(fmt.sprintf(sBag.getWeight(tok)));
                buf.append("*");
                buf.append(fmt.sprintf(tBag.getWeight(tok)));
            } else {
                // find best matching token
                double matchScore = tokenMatchThreshold;
                Token matchTok = null;
                for (Iterator<Token> j = tBag.tokenIterator(); j.hasNext();) {
                    Token tokJ = j.next();
                    double distItoJ = tokenDistance.score(tok.getValue(), tokJ.getValue());
                    if (distItoJ >= matchScore) {
                        matchTok = tokJ;
                        matchScore = distItoJ;
                    }
                }
                if (matchTok != null) {
                    buf.append(" '" + tok.getValue() + "'~='" + matchTok.getValue() + "': ");
                    buf.append(fmt.sprintf(sBag.getWeight(tok)));
                    buf.append("*");
                    buf.append(fmt.sprintf(tBag.getWeight(matchTok)));
                    buf.append("*");
                    buf.append(fmt.sprintf(matchScore));
                }
            }
        }
        buf.append("\nscore = " + score(s, t));
        return buf.toString();
    }
468997
public int getWeight(String classificationName)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getWeight", classificationName);
    
    int weight = 0;
    // Get the weight of the classification
    ClassWeight cw = messageClasses.get(classificationName);
    if(cw != null)
      weight = cw.getWeight();
     
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getWeight", Integer.valueOf(weight));
      
    return weight;
  }
1357845
def get_histogram(data):
    

    count = len(data)

    if count < 2:
        raise StatisticsError('Too few data points ({}) for get_histogram'.format(count))

    min_ = data[0]
    max_ = data[-1]
    std = stdev(data)

    bins = get_histogram_bins(min_, max_, std, count)

    res = {x: 0 for x in bins}

    for value in data:
        for bin_ in bins:
            if value <= bin_:
                res[bin_] += 1
                break

    return sorted(iteritems(res))
799969
public String explainScore(StringWrapper s,StringWrapper t) 
	{
		if (scaling) {
			int minLen = Math.min( s.unwrap().length(), t.unwrap().length() );
			double scaledDist =  super.score(s,t) / (minLen * CHAR_EXACT_MATCH_SCORE);
			return super.explainScore(s,t)
				+ "\nScaling factor: "+(minLen*CHAR_EXACT_MATCH_SCORE) 
				+ "\nScaled score: "+scaledDist;
		} else {
			return super.explainScore(s,t);
		}
	}
1294547
public String toPattern() {
		return _formats.stream()
			.map(Objects::toString)
			.collect(Collectors.joining());
	}