Package com.digitalpebble.classification

Examples of com.digitalpebble.classification.Vector


            int label = doc.getLabel();
            // get a vector from the document
            // need a metric (e.g. relative frequency / binary)
            // and a lexicon
            // the vector is represented as a string directly
            Vector vector = doc.getFeatureVector(lexicon);
            out.print(label + " " + Utils.getVectorString(vector) + "\n");
        }
        out.close();
        return vectorFile;
    }
View Full Code Here


            int label = doc.getLabel();
            // get a vector from the document
            // need a metric (e.g. relative frequency / binary)
            // and a lexicon
            // the vector is represented as a string directly
            Vector vector = null;
            if (attributeMapping == null)
                vector = doc.getFeatureVector(lexicon);
            else
                vector = doc.getFeatureVector(lexicon, attributeMapping);
            out.print(label + " " + Utils.getVectorString(vector) + "\n");
View Full Code Here

            int label = doc.getLabel();
            // get a vector from the document
            // need a metric (e.g. relative frequency / binary)
            // and a lexicon
            // the vector is represented as a string directly
            Vector vector = null;
            if (attributeMapping == null)
                vector = doc.getFeatureVector(lexicon);
            else
                vector = doc.getFeatureVector(lexicon, attributeMapping);

            StringBuffer buffer = new StringBuffer("{");

            buffer.append("0 ").append(lexicon.getLabel(label));

            // {1 X, 3 Y, 4 "class A"}
            // index space value
            int[] indices = vector.getIndices();
            double[] values = vector.getValues();
            for (int i = 0; i < indices.length; i++) {
                if (buffer.length() > 1)
                    buffer.append(", ");
                if (indices[i] > attributeNum)
                    continue;
View Full Code Here

   
    // convert docs into liblinear format
   
    List<FeatureNode> x = new ArrayList<FeatureNode>();
   
    Vector vector = document.getFeatureVector(this.lexicon);
   
    int[] indices = vector.getIndices();
    double[] values = vector.getValues();
   
    for (int indexpos = 0; indexpos < indices.length; indexpos++) {
      int index = indices[indexpos];
      if (index <= nr_feature) {
        FeatureNode node = new FeatureNode(index, values[indexpos]);
View Full Code Here

        Iterator<Document> docIter = corpus.iterator();
        while(docIter.hasNext()){
          Document d = docIter.next()
          // Vector vector = d.getFeatureVector(lexicon);
          // get a vector based on the number of occurrences i.e on the raw document
          Vector vector = d.getFeatureVector(lexicon,Parameters.WeightingMethod.OCCURRENCES);
          int[] indices = vector.getIndices();
          double[] values = vector.getValues();
          int classNum = d.getLabel();
         
          for (int i=0;i<indices.length;i++){
            int index = indices[i];
            double value = values[i];
View Full Code Here

     
      // fill the matrix
      Iterator<Document> docIter = corpus.iterator();
      while(docIter.hasNext()){
        Document d = docIter.next()
        Vector vector = d.getFeatureVector(lexicon);
        // get a vector based on the number of occurrences i.e on the raw document
        // Vector vector = d.getFeatureVector(lexicon,Parameters.WeightingMethod.OCCURRENCES);
        int[] indices = vector.getIndices();
        double[] values = vector.getValues();
        int classNum = d.getLabel();
       
        for (int i=0;i<indices.length;i++){
          int index = indices[i];
          double value = values[i];
View Full Code Here

            int label = doc.getLabel();
            // get a vector from the document
            // need a metric (e.g. relative frequency / binary)
            // and a lexicon
            // the vector is represented as a string directly
            Vector vector = doc.getFeatureVector(lexicon);
            out.print(label + " " + Utils.getVectorString(vector) + "\n");
        }
        out.close();
        return vectorFile;
    }
View Full Code Here

            int label = doc.getLabel();
            // get a vector from the document
            // need a metric (e.g. relative frequency / binary)
            // and a lexicon
            // the vector is represented as a string directly
            Vector vector = null;
            if (attributeMapping == null)
                vector = doc.getFeatureVector(lexicon);
            else
                vector = doc.getFeatureVector(lexicon, attributeMapping);
            out.print(label + " " + Utils.getVectorString(vector) + "\n");
View Full Code Here

            int label = doc.getLabel();
            // get a vector from the document
            // need a metric (e.g. relative frequency / binary)
            // and a lexicon
            // the vector is represented as a string directly
            Vector vector = null;
            if (attributeMapping == null)
                vector = doc.getFeatureVector(lexicon);
            else
                vector = doc.getFeatureVector(lexicon, attributeMapping);

            StringBuffer buffer = new StringBuffer("{");

            buffer.append("0 ").append(lexicon.getLabel(label));

            // {1 X, 3 Y, 4 "class A"}
            // index space value
            int[] indices = vector.getIndices();
            double[] values = vector.getValues();
            for (int i = 0; i < indices.length; i++) {
                if (buffer.length() > 1)
                    buffer.append(", ");
                if (indices[i] > attributeNum)
                    continue;
View Full Code Here

            int label = doc.getLabel();
            // get a vector from the document
            // need a metric (e.g. relative frequency / binary)
            // and a lexicon
            // the vector is represented as a string directly
            Vector vector = null;
            if (attributeMapping == null)
                vector = doc.getFeatureVector(lexicon);
            else
                vector = doc.getFeatureVector(lexicon, attributeMapping);

            StringBuffer buffer = new StringBuffer();

            buffer.append(lexicon.getLabel(label));

            int[] indices = vector.getIndices();
            double[] values = vector.getValues();

            double[] denseVector = new double[attributeNum];

            for (int i = 0; i < indices.length; i++) {
                int currentIndex = indices[i];
View Full Code Here

TOP

Related Classes of com.digitalpebble.classification.Vector

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.