Examples of numLocations()


Examples of cc.mallet.types.AugmentableFeatureVector.numLocations()

  public Instance pipe (Instance carrier)
  {
    AugmentableFeatureVector afv = (AugmentableFeatureVector)carrier.getData();
    double v;
    for (int i = afv.numLocations() - 1; i >= 0; i--) {
      v = afv.valueAtLocation (i);
      if (v >= 1)
        afv.setValueAtLocation (i, Math.log(v)+1);
    }
    return carrier;
View Full Code Here

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

            FeatureVector input = (FeatureVector)ti.getInput();
            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)))
View Full Code Here

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

            FeatureVector input = (FeatureVector)ti.getInput();
            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)))
View Full Code Here

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

    StringBuffer b = new StringBuffer();
    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.numLocations()

    for (int ii = 0; ii < trainingList.size(); ii++){
      Instance inst = (Instance) trainingList.get(ii);
      Labeling labeling = inst.getLabeling ();
      FeatureVector fv = (FeatureVector) inst.getData ();
      double[] results = new double [numLabels];
      int fvisize = fv.numLocations();
      int correctIndex = labeling.getBestIndex();
     
      for(int rpos=0; rpos < numLabels; rpos++)
        results[rpos]=0;
      // sum up xi*wi for each class
View Full Code Here

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

    FeatureVector fv;
    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);
          }
View Full Code Here

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

      MatrixOps.rowPlusEquals (constraints, numFeatures, li, fv, instanceWeight);
      // For the default feature, whose weight is 1.0
      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;
        }
      }
View Full Code Here

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

    FeatureVector fv;
    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);
          }
View Full Code Here

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

    FeatureVector fv = (FeatureVector) instance.getData ();
    // Make sure the feature vector's feature dictionary matches
    // what we are expecting from our data pipe (and thus our notion
    // of feature probabilities.
    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++)
View Full Code Here

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

    FeatureVector fv;
    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);
          }
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.