Example #1
0
  /**
   * Determine the list of test instances and the list of training instances.
   *
   * @param prefix
   * @param type
   * @param prune
   */
  public void prepare(String prefix, SequenceType type) {
    _classNames = Utils.getActivityNames(prefix);
    _testMap = getTestSet(_classNames);

    // build a training set and a test set.
    _training = new HashMap<String, List<Instance>>();
    _testing = new ArrayList<Instance>();

    // Now train up the signatures...
    for (String className : _classNames) {
      File dataFile = new File("data/input/" + className + ".lisp");
      List<Instance> instances = Utils.sequences(className, dataFile.getAbsolutePath(), type);
      List<Integer> testSet = _testMap.get(className);

      for (Instance instance : instances) {
        if (testSet.contains(instance.id())) _testing.add(instance);
        else {
          List<Instance> list = _training.get(instance.name());
          if (list == null) {
            list = new ArrayList<Instance>();
            _training.put(instance.name(), list);
          }
          list.add(instance);
        }
      }
    }
  }