Esempio n. 1
0
  /**
   * Test method for {@link com.jgaap.distances.NominalKSDistance#distance(com.jgaap.util.EventSet,
   * com.jgaap.util.EventSet)}.
   */
  @Test
  public void testDistance() {
    EventSet es1 = new EventSet();
    EventSet es2 = new EventSet();
    Vector<Event> test1 = new Vector<Event>();
    test1.add(new Event("The", null));
    test1.add(new Event("quick", null));
    test1.add(new Event("brown", null));
    test1.add(new Event("fox", null));
    test1.add(new Event("jumps", null));
    test1.add(new Event("over", null));
    test1.add(new Event("the", null));
    test1.add(new Event("lazy", null));
    test1.add(new Event("dog", null));
    test1.add(new Event(".", null));
    es1.addEvents(test1);
    es2.addEvents(test1);

    assertTrue(new NominalKSDistance().distance(new EventMap(es1), new EventMap(es2)) == 0.00);

    Vector<Event> test2 =
        new Vector<
            Event>(); // set with the same number of elements, only one repeats and none are the
                      // same as in test1
    test2.add(new Event("33", null));
    test2.add(new Event("5", null));
    test2.add(new Event("6", null));
    test2.add(new Event("8", null));
    test2.add(new Event("44", null));
    test2.add(new Event("7", null));
    test2.add(new Event("33", null));
    test2.add(new Event("10", null));
    test2.add(new Event("2", null));
    test2.add(new Event("..", null));
    es2 = new EventSet();
    es2.addEvents(test2);
    double result = new NominalKSDistance().distance(new EventMap(es1), new EventMap(es2));
    assertTrue(DistanceTestHelper.inRange(result, 1.00, 0.0000000001));
  }
Esempio n. 2
0
  @Test
  public void testProcess() throws EventCullingException {
    List<EventSet> eventSets = new ArrayList<EventSet>();
    EventSet eventSet1 = new EventSet();
    eventSet1.addEvent(new Event("A", null));
    eventSet1.addEvent(new Event("A", null));
    eventSet1.addEvent(new Event("A", null));
    eventSet1.addEvent(new Event("A", null));
    eventSet1.addEvent(new Event("A", null));
    eventSet1.addEvent(new Event("B", null));
    eventSet1.addEvent(new Event("B", null));
    eventSet1.addEvent(new Event("B", null));
    eventSet1.addEvent(new Event("C", null));
    eventSets.add(eventSet1);
    EventSet eventSet2 = new EventSet();
    eventSet2.addEvent(new Event("A", null));
    eventSet2.addEvent(new Event("B", null));
    eventSet2.addEvent(new Event("C", null));
    eventSet2.addEvent(new Event("D", null));
    eventSet2.addEvent(new Event("E", null));
    eventSet2.addEvent(new Event("F", null));
    eventSet2.addEvent(new Event("F", null));
    eventSet2.addEvent(new Event("G", null));
    eventSet2.addEvent(new Event("H", null));
    eventSets.add(eventSet2);
    EventSet eventSet3 = new EventSet();
    eventSet3.addEvent(new Event("E", null));
    eventSet3.addEvent(new Event("E", null));
    eventSet3.addEvent(new Event("E", null));
    eventSet3.addEvent(new Event("F", null));
    eventSet3.addEvent(new Event("A", null));
    eventSet3.addEvent(new Event("B", null));
    eventSet3.addEvent(new Event("D", null));
    eventSet3.addEvent(new Event("H", null));
    eventSet3.addEvent(new Event("C", null));
    eventSets.add(eventSet3);

    WeightedVariance culler = new WeightedVariance();
    culler.setParameter("numEvents", 4);
    Set<Event> results = culler.train(eventSets);
    Set<Event> expected = new HashSet<Event>();
    expected.add(new Event("A", null));
    expected.add(new Event("B", null));
    expected.add(new Event("E", null));
    expected.add(new Event("F", null));
    assertTrue(results.equals(expected));
  }