Package com.digitalpebble.classification

Examples of com.digitalpebble.classification.Vector


    int[] labels = new int[nr_class];
    svm.svm_get_labels(model, labels);
    boolean support_probabilities = svm.svm_check_probability_model(model) == 1;
    double[] scores = new double[nr_class];
    // creates nodes from document
    Vector vector = document.getFeatureVector(this.lexicon);
    int[] indices = vector.getIndices();
    double[] values = vector.getValues();
    svm_node[] svm_nodes = new svm_node[indices.length];
    for(int n = 0; n < svm_nodes.length; n++) {
      svm_nodes[n] = new svm_node();
      svm_nodes[n].index = indices[n];
      svm_nodes[n].value = values[n];
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

    Field[] fields = new Field[1];
    fields[0] = new Field("keywords", new String[] { "test","keywords"});
    learner.setMethod(Parameters.WeightingMethod.FREQUENCY);
    learner.getLexicon().setMethod(Parameters.WeightingMethod.BOOLEAN, "keywords");
    Document doc = learner.createDocument(fields, "large");
    Vector vector = doc.getFeatureVector(learner.getLexicon());
   
    // check that the values for the field keywords are boolean
    int[] indices = vector.getIndices();
    double[] values = vector.getValues();
   
    Map<Integer, String> invertedIndex = learner.getLexicon()
    .getInvertedIndex();
   
    for (int i = 0; i < indices.length; i++) {
View Full Code Here

    assertEquals(expectedset.size(), corpus.size());

    for (Map<String, Double> ref : expectedset) {
      Document doc = corpusIter.next();
      Vector vector = doc.getFeatureVector(learner.getLexicon());
      // now let's compare what we wanted to have with the content of the
      // vector
      int[] indices = vector.getIndices();
      double[] values = vector.getValues();

      // compare size of indices with reference
      assertEquals(ref.size(), indices.length);

      for (int i = 0; i < indices.length; 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.