Package com.jgaap.util

Examples of com.jgaap.util.Instance


    /*
     * Put together the training set
     */
    for (int i = 0; i < knownEventMaps.size(); i++) {
      EventMap knownEventMap = knownEventMaps.get(i);
      Instance currentTrainingDocument = new Instance(
          allEvents.size() + 1);
      currentTrainingDocument.setValue((Attribute) attributeList
          .elementAt(0), knownDocuments.get(i).getAuthor());
      int j = 1; // Start counting events (at 1, since 0 is the author
            // label)
      for (Event event : allEvents) {
        currentTrainingDocument.setValue(
            (Attribute) attributeList.elementAt(j),
            knownEventMap.normalizedFrequency(event));
        j++;
      }
      trainingSet.add(new SparseInstance(currentTrainingDocument));
View Full Code Here


    /*
     * Generate the test sets, classifying each one as we go
     */
    List<Pair<String, Double>> result = new ArrayList<Pair<String, Double>>();
    EventMap eventMap = new EventMap(unknownDocument);
    Instance currentTest = new Instance(allEvents.size() + 1);

    currentTest.setValue((Attribute) attributeList.elementAt(0), "Unknown");
    int i = 1; // Start at 1, again
    for (Event event : allEvents) {
      currentTest.setValue((Attribute) attributeList.elementAt(i),
          eventMap.normalizedFrequency(event));
      i++;
    }
   
    currentTest.setDataset(trainingSet);

    double[] probDistribution;
    try {
      probDistribution = classifier.distributionForInstance(currentTest);
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of com.jgaap.util.Instance

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.