Package cc.mallet.types

Examples of cc.mallet.types.RankedFeatureVector$PerLabelFactory


        out.println ("WEIGHTS NAME = " + parameters.weightAlphabet.lookupObject (widx));
        out.print (": <DEFAULT_FEATURE> = "); out.print (parameters.defaultWeights[widx]); out.print ('\n');
        SparseVector transitionWeights = parameters.weights[widx];
        if (transitionWeights.numLocations () == 0)
          continue;
        RankedFeatureVector rfv = new RankedFeatureVector (inputAlphabet, transitionWeights);
        for (int m = 0; m < rfv.numLocations (); m++) {
          double v = rfv.getValueAtRank (m);
          //int index = rfv.indexAtLocation (rfv.getIndexAtRank (m));  // This doesn't make any sense.  How did this ever work?  -akm 12/2007
          int index = rfv.getIndexAtRank (m);
          Object feature = inputAlphabet.lookupObject (index);
          if (v != 0) {
            out.print (": "); out.print (feature); out.print (" = "); out.println (v);
          }
        }
View Full Code Here


            vals[k] = w.value (index) * input.value (index);
            absVals[k] = Math.abs (vals[k]);
          }

          buf.append ("DEFAULT " + f.format (crf.parameters.defaultWeights[wi]) + "<br />\n");
          RankedFeatureVector rfv = new RankedFeatureVector (crf.inputAlphabet, input.getIndices (), absVals);
          for (int rank = 0; rank < absVals.length; rank++) {
            int fidx = rfv.getIndexAtRank (rank);
            Object fname = crf.inputAlphabet.lookupObject (input.indexAtLocation (fidx));
            if (absVals[fidx] < cutoff) break; // Break looping over features
            if (vals[fidx] != 0) {
              buf.append (fname + " " + f.format (vals[fidx]) + "<br />\n");
            }
View Full Code Here

    final LabelAlphabet labelDict = getLabelAlphabet();

    int numFeatures = dict.size() + 1;
    int numLabels = labelDict.size();
  // Include the feature weights according to each label
    RankedFeatureVector rfv;
    double[] weights = new double[numFeatures-1]; // do not deal with the default feature
    for (int li = 0; li < numLabels; li++) {
      out.print ("FEATURES FOR CLASS "+labelDict.lookupObject (li) + " ");
      for (int i = 0; i < defaultFeatureIndex; i++) {
        double weight = parameters [li*numFeatures + i];
        weights[i] = weight;
      }
      rfv = new RankedFeatureVector(dict,weights);
      rfv.printByRank(out);
      out.println (" <default> "+parameters [li*numFeatures + defaultFeatureIndex] + " ");
    }
  }
View Full Code Here

    int numFeatures = dict.size() + 1;
    int numLabels = labelDict.size();

    // Include the feature weights according to each label
    RankedFeatureVector rfv;
    double[] weights = new double[numFeatures-1]; // do not deal with the default feature
    for (int li = 0; li < numLabels; li++) {
      out.print ("FEATURES FOR CLASS "+labelDict.lookupObject (li) + " ");
      for (int i = 0; i < defaultFeatureIndex; i++) {
        Object name = dict.lookupObject (i);
        double weight = parameters [li*numFeatures + i];
        weights[i] = weight;
      }
      rfv = new RankedFeatureVector(dict,weights);
      rfv.printTopK(out,num);
      out.print (" <default> "+parameters [li*numFeatures + defaultFeatureIndex] + " ");
      rfv.printLowerK(out, num);
      out.println();
    }
  }
View Full Code Here

    final LabelAlphabet labelDict = getLabelAlphabet();

    int numFeatures = dict.size() + 1;
    int numLabels = labelDict.size();
  // Include the feature weights according to each label
    RankedFeatureVector rfv;
    double[] weights = new double[numFeatures-1]; // do not deal with the default feature
    for (int li = 0; li < numLabels; li++) {
      out.print ("FEATURES FOR CLASS "+labelDict.lookupObject (li) + " ");
      for (int i = 0; i < defaultFeatureIndex; i++) {
        double weight = parameters [li*numFeatures + i];
        weights[i] = weight;
      }
      rfv = new RankedFeatureVector(dict,weights);
      rfv.printByRank(out);
      out.println (" <default> "+parameters [li*numFeatures + defaultFeatureIndex] + " ");
    }
  }
View Full Code Here

    int numFeatures = dict.size() + 1;
    int numLabels = labelDict.size();

    // Include the feature weights according to each label
    RankedFeatureVector rfv;
    double[] weights = new double[numFeatures-1]; // do not deal with the default feature
    for (int li = 0; li < numLabels; li++) {
      out.print ("FEATURES FOR CLASS "+labelDict.lookupObject (li) + " ");
      for (int i = 0; i < defaultFeatureIndex; i++) {
        Object name = dict.lookupObject (i);
        double weight = parameters [li*numFeatures + i];
        weights[i] = weight;
      }
      rfv = new RankedFeatureVector(dict,weights);
      rfv.printTopK(out,num);
      out.print (" <default> "+parameters [li*numFeatures + defaultFeatureIndex] + " ");
      rfv.printLowerK(out, num);
      out.println();
    }
  }
View Full Code Here

        out.println ("WEIGHTS NAME = " + parameters.weightAlphabet.lookupObject (widx));
        out.print (": <DEFAULT_FEATURE> = "); out.print (parameters.defaultWeights[widx]); out.print ('\n');
        SparseVector transitionWeights = parameters.weights[widx];
        if (transitionWeights.numLocations () == 0)
          continue;
        RankedFeatureVector rfv = new RankedFeatureVector (inputAlphabet, transitionWeights);
        for (int m = 0; m < rfv.numLocations (); m++) {
          double v = rfv.getValueAtRank (m);
          //int index = rfv.indexAtLocation (rfv.getIndexAtRank (m));  // This doesn't make any sense.  How did this ever work?  -akm 12/2007
          int index = rfv.getIndexAtRank (m);
          Object feature = inputAlphabet.lookupObject (index);
          if (v != 0) {
            out.print (": "); out.print (feature); out.print (" = "); out.println (v);
          }
        }
View Full Code Here

            vals[k] = w.value (index) * input.value (index);
            absVals[k] = Math.abs (vals[k]);
          }

          buf.append ("DEFAULT " + f.format (crf.parameters.defaultWeights[wi]) + "<br />\n");
          RankedFeatureVector rfv = new RankedFeatureVector (crf.inputAlphabet, input.getIndices (), absVals);
          for (int rank = 0; rank < absVals.length; rank++) {
            int fidx = rfv.getIndexAtRank (rank);
            Object fname = crf.inputAlphabet.lookupObject (input.indexAtLocation (fidx));
            if (absVals[fidx] < cutoff) break; // Break looping over features
            if (vals[fidx] != 0) {
              buf.append (fname + " " + f.format (vals[fidx]) + "<br />\n");
            }
View Full Code Here

    final LabelAlphabet labelDict = getLabelAlphabet();

    int numFeatures = dict.size() + 1;
    int numLabels = labelDict.size();
  // Include the feature weights according to each label
    RankedFeatureVector rfv;
    double[] weights = new double[numFeatures-1]; // do not deal with the default feature
    for (int li = 0; li < numLabels; li++) {
      out.print ("FEATURES FOR CLASS "+labelDict.lookupObject (li) + " ");
      for (int i = 0; i < defaultFeatureIndex; i++) {
        double weight = parameters [li*numFeatures + i];
        weights[i] = weight;
      }
      rfv = new RankedFeatureVector(dict,weights);
      rfv.printByRank(out);
      out.println (" <default> "+parameters [li*numFeatures + defaultFeatureIndex] + " ");
    }
  }
View Full Code Here

    int numFeatures = dict.size() + 1;
    int numLabels = labelDict.size();

    // Include the feature weights according to each label
    RankedFeatureVector rfv;
    double[] weights = new double[numFeatures-1]; // do not deal with the default feature
    for (int li = 0; li < numLabels; li++) {
      out.print ("FEATURES FOR CLASS "+labelDict.lookupObject (li) + " ");
      for (int i = 0; i < defaultFeatureIndex; i++) {
        Object name = dict.lookupObject (i);
        double weight = parameters [li*numFeatures + i];
        weights[i] = weight;
      }
      rfv = new RankedFeatureVector(dict,weights);
      rfv.printTopK(out,num);
      out.print (" <default> "+parameters [li*numFeatures + defaultFeatureIndex] + " ");
      rfv.printLowerK(out, num);
      out.println();
    }
  }
View Full Code Here

TOP

Related Classes of cc.mallet.types.RankedFeatureVector$PerLabelFactory

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.