Example #1
0
  /**
   * Select a random set to be the test set.
   *
   * @param classNames
   * @return
   */
  public Map<String, List<Integer>> getTestSet(List<String> classNames) {
    Random r = new Random(System.currentTimeMillis());

    Map<String, List<Integer>> testSet = new HashMap<String, List<Integer>>();

    for (String className : classNames) {
      String f = "data/input/" + className + ".lisp";
      Map<Integer, List<Interval>> map = Utils.load(new File(f));
      List<Integer> episodes = new ArrayList<Integer>(map.keySet());
      Collections.shuffle(episodes, r);

      // 33% of the instances will be part of the test set
      double pct = 1.0 / 3.0;
      int number = (int) Math.round((double) episodes.size() * pct);

      List<Integer> list = new ArrayList<Integer>();
      for (int i = 0; i < number; ++i) {
        list.add(episodes.get(i));
      }
      testSet.put(className, list);
    }

    return testSet;
  }