Package gnu.trove

Examples of gnu.trove.TObjectDoubleHashMap


   
    if (label != null && !label.equals(Constants.GetDummyLabel())) {
        SetGoldLabel(label, weight);
    }
   
    this.neighbors_ = new TObjectDoubleHashMap();
    this.isSeedNode_ = false;
    this.isTestNode_ = false;
    this.features_ = new RyanFeatureVector(-1, -1, null);

    // initialize the estimated labels with dummy label
View Full Code Here


    // TODO(partha): temporarily commented for working with WebKB data
    // on 03/26/2009. need to decide whether to make it permanent.
    //    if (!isTransitionNormalized) {
    //      NormalizeTransitionProbability();
    //    }
    TObjectDoubleHashMap neighborClone = this.neighbors_.clone();
    Normalize(neighborClone);
   
    double ent = GetNeighborhoodEntropy(neighborClone);
    double cv = Math.log(beta) / Math.log(beta + ent);
   
View Full Code Here

  }

  public static TObjectDoubleHashMap String2Map(TObjectDoubleHashMap retMap,
                                                String inp) {
    if (retMap == null) {
      retMap = new TObjectDoubleHashMap();
    }

    if (inp.length() > 0) {
      String[] fields = inp.split(" ");
      for (int i = 0; i < fields.length; i += 2) {
View Full Code Here

    res.table = inp.table.clone();   
    return res;
  }
 
  public TObjectDoubleHashMap getLabelScores(CountMinSketchLabel labelScores) {
    TObjectDoubleHashMap ret = new TObjectDoubleHashMap();
   
    if (labelScores != null) {
      Iterator labIter = la.iterator();
      while (labIter.hasNext()) {
        String lab = (String) labIter.next();

        float score = getScore(labelScores, getLabelHash(lab));
        if (score > 0) {
          ret.put(lab, score);
        }
      }
    }
    return (ret);
  }
View Full Code Here

    Iterator<String> vIter = _vertices.keySet().iterator();
    while (vIter.hasNext()) {
      Vertex2 v = _vertices.get(vIter.next());
     
      Object[] neighNames = v.GetNeighborNames();
      TObjectDoubleHashMap neighWeights = new TObjectDoubleHashMap();
      int totalNeighbors = neighNames.length;
      for (int ni = 0; ni < totalNeighbors; ++ni) {
        neighWeights.put(neighNames[ni], v.GetNeighborWeight((String) neighNames[ni]));
      }
      // now sort the neighbors
      ArrayList<ObjectDoublePair> sortedNeighList = CollectionUtil2.ReverseSortMap(neighWeights);
     
      // Since the array is reverse sorted, the highest scoring
View Full Code Here

  //
  // CPN is different from Class Mass Normalization (CMN) as CMN is used post
  // classification, while CPN is used before the classification process is
  // started.
  public void ClassPriorNormalization() {
    TObjectDoubleHashMap labels = new TObjectDoubleHashMap();
   
    // compute class weight sum
    TObjectDoubleHashMap classSeedSum = new TObjectDoubleHashMap();
    Iterator<String> viter0 = this._vertices.keySet().iterator();
    while (viter0.hasNext()) {
      String vName = viter0.next();
      Vertex2 v = _vertices.get(vName);
      if (v.IsSeedNode()) {
        TObjectDoubleIterator injLabIter =
            this._labelManager.getLabelScores(v.GetInjectedLabelScores()).iterator();
        while (injLabIter.hasNext()) {
          injLabIter.advance();
          double currVal = classSeedSum.containsKey(injLabIter.key()) ?
            classSeedSum.get(injLabIter.key()) : 0;
          classSeedSum.put(injLabIter.key(), currVal + injLabIter.value());
         
          // add the label to the list of labels
          if (!labels.containsKey(injLabIter.key())) {
            labels.put(injLabIter.key(), 1.0);
          }
        }
      }
    }
   
    double[] seedWeightSums = classSeedSum.getValues();
    double maxSum = -1;
    for (int wsi = 0; wsi < seedWeightSums.length; ++wsi) {
      if (seedWeightSums[wsi] > maxSum) {
        maxSum = seedWeightSums[wsi];
      }
    }
   
    TObjectDoubleHashMap seedAmpliFactor = new TObjectDoubleHashMap();
    TObjectDoubleIterator wIter = classSeedSum.iterator();
    while (wIter.hasNext()) {
      wIter.advance();
      seedAmpliFactor.put(wIter.key(), maxSum / wIter.value());
      System.out.println("Label: " + wIter.key() +
                         " ampli_factor: " + seedAmpliFactor.get(wIter.key()));
    }
   
    // now multiply injected scores with amplification factors
    Iterator<String> viter = this._vertices.keySet().iterator();
    while (viter.hasNext()) {
      String vName = viter.next();
      Vertex2 v = _vertices.get(vName);
      if (v.IsSeedNode()) {       
        TObjectDoubleIterator injLabIter =
            this._labelManager.getLabelScores(v.GetInjectedLabelScores()).iterator();
        while (injLabIter.hasNext()) {
          injLabIter.advance();
         
          double currVal = injLabIter.value();
          injLabIter.setValue(currVal * seedAmpliFactor.get(injLabIter.key()));
        }
      }
    }
  }
View Full Code Here

      newDist.clear();
     
      int totalNodes = g._vertices.size();
//      double deltaLabelDiffPerNode = (1.0 * deltaLabelDiff) / totalNodes;

      TObjectDoubleHashMap res = new TObjectDoubleHashMap();
      res.put(Constants.GetMRRString(), Graph2.GetAverageTestMRR(g));
      res.put(Constants.GetPrecisionString(), Graph2.GetAccuracy(g));
      resultList.add(res);
//      if (verbose) {
//        System.out.println("after_iteration " + iter +
//                           " objective: " + GetObjective(g, mu1, mu2, mu3) +
//                           " accuracy: " + res.get(Constants.GetPrecisionString()) +
//                           " rmse: " + GraphEval.GetRMSE(g) +
//                           " time: " + (endTime - startTime) +
//                           " label_diff_per_node: " + deltaLabelDiffPerNode +
//                           " mrr_train: " + GraphEval.GetAverageTrainMRR(g) +
//                           " mrr_test: " + res.get(Constants.GetMRRString()) +
//                           " column_updates: " + totalColumnUpdates +
//                           " entity_updates: " + totalEntityUpdates + "\n");
//      }
     
//      if (false && deltaLabelDiffPerNode <= Constants.GetStoppingThreshold()) {
//        if (useBipartitieOptimization) {
//          if (iter > 1 && iter % 2 == 1) {
//            MessagePrinter.Print("Convergence reached!!");
//            break;
//          }
//        } else {
//          MessagePrinter.Print("Convergence reached!!");
//          break;
//        }
//      }
    }
   
    if (resultList.size() > 0) {
      TObjectDoubleHashMap res =
        (TObjectDoubleHashMap) resultList.get(resultList.size() - 1);
      MessagePrinter.Print(Constants.GetPrecisionString() + " " +
                           res.get(Constants.GetPrecisionString()));
      MessagePrinter.Print(Constants.GetMRRString() + " " +
                           res.get(Constants.GetMRRString()));
    }
  }
View Full Code Here

TOP

Related Classes of gnu.trove.TObjectDoubleHashMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.