Examples of indexAtLocation()


Examples of cc.mallet.types.FeatureVector.indexAtLocation()

            int index = ti.getIndex();
            int nwi = source.weightsIndices[index].length;
            for (int wi = 0; wi < nwi; wi++) {
              int weightsIndex = source.weightsIndices[index][wi];
              for (int i = 0; i < input.numLocations(); i++) {
                int featureIndex = input.indexAtLocation(i);
                if ((globalFeatureSelection == null || globalFeatureSelection.contains(featureIndex))
                    && (featureSelections == null
                        || featureSelections[weightsIndex] == null
                        || featureSelections[weightsIndex].contains(featureIndex)))
                  weightsPresent[weightsIndex].set (featureIndex);
View Full Code Here

Examples of cc.mallet.types.FeatureVector.indexAtLocation()

            int index = ti.getIndex();
            int nwi = source.weightsIndices[index].length;
            for (int wi = 0; wi < nwi; wi++) {
              int weightsIndex = source.weightsIndices[index][wi];
              for (int i = 0; i < input.numLocations(); i++) {
                int featureIndex = input.indexAtLocation(i);
                if ((globalFeatureSelection == null || globalFeatureSelection.contains(featureIndex))
                    && (featureSelections == null
                        || featureSelections[weightsIndex] == null
                        || featureSelections[weightsIndex].contains(featureIndex)))
                  weightsPresent[weightsIndex].set (featureIndex);
View Full Code Here

Examples of cc.mallet.types.FeatureVector.indexAtLocation()

    return value(fieldAlph.lookupIndex(field));
  }
 
  public int value (int field) {
    FeatureVector fv = values(field);
    return (fv == null) ? -1 : fv.indexAtLocation(0);
  }
 
  public int[] fields () { return field2values.keys(); }
 
  public Alphabet fieldAlphabet () { return this.fieldAlph; }
View Full Code Here

Examples of cc.mallet.types.FeatureVector.indexAtLocation()

    int[] keys = field2values.keys();
    for (int i = 0; i < keys.length; i++) {
      b.append(fieldAlph.lookupObject(keys[i]) + "=");
      FeatureVector v = (FeatureVector) field2values.get(keys[i]);
      for (int j = 0; j < v.numLocations(); j++)
        b.append(valueAlph.lookupObject(v.indexAtLocation(j)) + ",");
      if (!oneLine) b.append("\n");
    }
    return b.toString();
  }
View Full Code Here

Examples of cc.mallet.types.FeatureVector.indexAtLocation()

     
      for(int rpos=0; rpos < numLabels; rpos++)
        results[rpos]=0;
      // sum up xi*wi for each class
      for(int fvi=0; fvi < fvisize; fvi++){
        int fi = fv.indexAtLocation(fvi);
        //System.out.println("feature index "+fi);
        for(int lpos=0; lpos < numLabels; lpos++)
          results[lpos] += this.weights[lpos][fi];
      }
      //System.out.println("In instance " + ii);
View Full Code Here

Examples of cc.mallet.types.FeatureVector.indexAtLocation()

    BitSet bitSet = new BitSet(data.size());
    for (Instance instance : data) {
      double weight = data.getInstanceWeight(instance);
      fv = (FeatureVector)instance.getData();
      for (int loc = 0; loc < fv.numLocations(); loc++) {
        fi = fv.indexAtLocation(loc);
        if (constraints.containsKey(fi)) {
          if (useValues) {
            constraints.get(fi).count += weight * fv.valueAtLocation(loc);
          }
          else {
View Full Code Here

Examples of cc.mallet.types.FeatureVector.indexAtLocation()

      assert(!Double.isNaN(instanceWeight)) : "instanceWeight is NaN";
      assert(!Double.isNaN(li)) : "bestIndex is NaN";
      boolean hasNaN = false;
      for (int i = 0; i < fv.numLocations(); i++) {
        if(Double.isNaN(fv.valueAtLocation(i))) {
          logger.info("NaN for feature " + fdict.lookupObject(fv.indexAtLocation(i)).toString());
          hasNaN = true;
        }
      }
      if (hasNaN)
        logger.info("NaN in instance: " + inst.getName());
View Full Code Here

Examples of cc.mallet.types.FeatureVector.indexAtLocation()

    BitSet bitSet = new BitSet(data.size());
    for (Instance instance : data) {
      double weight = data.getInstanceWeight(instance);
      fv = (FeatureVector)instance.getData();
      for (int loc = 0; loc < fv.numLocations(); loc++) {
        fi = fv.indexAtLocation(loc);
        if (constraints.containsKey(fi)) {
          if (useValues) {
            constraints.get(fi).count += weight * fv.valueAtLocation(loc);
          }
          else {
View Full Code Here

Examples of cc.mallet.types.FeatureVector.indexAtLocation()

    assert (instancePipe == null || fv.getAlphabet () == this.instancePipe.getDataAlphabet ());
    int fvisize = fv.numLocations();
   
    // Set the scores by summing wi*xi
    for (int fvi = 0; fvi < fvisize; fvi++) {
      int fi = fv.indexAtLocation (fvi);
      for (int ci = 0; ci < numClasses; ci++)
        scores[ci] += this.weights[ci][fi];
    }
   
   
View Full Code Here

Examples of cc.mallet.types.FeatureVector.indexAtLocation()

    BitSet bitSet = new BitSet(data.size());
    for (Instance instance : data) {
      double weight = data.getInstanceWeight(instance);
      fv = (FeatureVector)instance.getData();
      for (int loc = 0; loc < fv.numLocations(); loc++) {
        fi = fv.indexAtLocation(loc);
        if (constraints.containsKey(fi)) {
          if (useValues) {
            constraints.get(fi).count += weight * fv.valueAtLocation(loc);
          }
          else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.