List of usage examples for org.apache.commons.lang3.tuple Pair getValue
@Override
public R getValue()
Gets the value from this pair.
This method implements the Map.Entry interface returning the right element as the value.
From source file:sadl.detectors.PdttaWithPreprocessingTest.java
@Test public void test() throws URISyntaxException, IOException { final PdttaLearner learner = new PdttaLearner(new AlergiaRedBlue(0.05, true)); // final AggregatedThresholdDetector detector = new AggregatedThresholdDetector(ProbabilityAggregationMethod.NORMALIZED_MULTIPLY, -5, -8, // false);/*ww w . j av a 2 s . c o m*/ final AnomalyDetector detector = new VectorDetector(ProbabilityAggregationMethod.NORMALIZED_MULTIPLY, new AggregatedSingleFeatureCreator(), new ThresholdClassifier(Math.exp(-5))); final Path p = Paths.get(this.getClass().getResource("/pdtta/smac_mix_type1.txt").toURI()); final Pair<TimedInput, TimedInput> trainTest = IoUtils.readTrainTestFile(p); final ButlaPdtaLearner butla = new ButlaPdtaLearner(20000, EventsCreationStrategy.SplitEvents, KDEFormelVariant.OriginalKDE); // final ButlaPdtaLearner butla = new ButlaPdtaLearner(EventsCreationStrategy.SplitEvents, KDEFormelVariant.OriginalKDE); final Pair<TimedInput, Map<String, Event>> pair = butla.splitEventsInTimedSequences(trainTest.getKey()); final TimedInput splittedTrainSet = pair.getKey(); final Map<String, Event> eventMapping = pair.getValue(); final PDTTA model = learner.train(splittedTrainSet); detector.setModel(model); final AnomalyDetection detection = new AnomalyDetection(detector, model); final TimedInput testSet = butla.getSplitInputForMapping(trainTest.getValue(), eventMapping); final ExperimentResult result = detection.test(testSet); final ExperimentResult expected = new ExperimentResult(467, 4421, 112, 0); assertEquals(expected, result); }
From source file:sadl.modellearner.AlergiaTest.java
@Test public void testLoopBigNonRecPaperMerge() throws URISyntaxException, IOException { final Alergia alergia = new Alergia(0.05, false, MergeMethod.ALERGIA_PAPER); final Pair<TimedInput, TimedInput> trainTest = IoUtils .readTrainTestFile(Paths.get(this.getClass().getResource("/pdtta/smac_mix_type1.txt").toURI())); final PDFA pdfa = alergia.train(trainTest.getKey()); final AnomalyDetector detector = new VectorDetector(ProbabilityAggregationMethod.NORMALIZED_MULTIPLY, new AggregatedSingleFeatureCreator(), new ThresholdClassifier(Math.exp(-5))); final AnomalyDetection detection = new AnomalyDetection(detector, pdfa); final ExperimentResult expected = new ExperimentResult(467, 4531, 2, 0); final ExperimentResult actual = detection.test(trainTest.getValue()); assertEquals(expected, actual);/*from w w w . j av a 2 s . com*/ assertEquals(808, pdfa.getStateCount()); }
From source file:sadl.modellearner.AlergiaTest.java
@Test public void testLoopBigNonRecTrebaMerge() throws URISyntaxException, IOException { final Alergia alergia = new Alergia(0.05, false, MergeMethod.TREBA); final Pair<TimedInput, TimedInput> trainTest = IoUtils .readTrainTestFile(Paths.get(this.getClass().getResource("/pdtta/smac_mix_type1.txt").toURI())); final PDFA pdfa = alergia.train(trainTest.getKey()); final AnomalyDetector detector = new VectorDetector(ProbabilityAggregationMethod.NORMALIZED_MULTIPLY, new AggregatedSingleFeatureCreator(), new ThresholdClassifier(Math.exp(-5))); final AnomalyDetection detection = new AnomalyDetection(detector, pdfa); final ExperimentResult expected = new ExperimentResult(467, 4531, 2, 0); final ExperimentResult actual = detection.test(trainTest.getValue()); assertEquals(expected, actual);//from w w w . j a va 2s . c om assertEquals(808, pdfa.getStateCount()); }
From source file:sadl.modellearner.AlergiaTest.java
@Test public void testLoopBigRecPaperMerge() throws URISyntaxException, IOException { final Alergia alergia = new Alergia(0.05, true, MergeMethod.ALERGIA_PAPER); final Pair<TimedInput, TimedInput> trainTest = IoUtils .readTrainTestFile(Paths.get(this.getClass().getResource("/pdtta/smac_mix_type1.txt").toURI())); final PDFA pdfa = alergia.train(trainTest.getKey()); final AnomalyDetector detector = new VectorDetector(ProbabilityAggregationMethod.NORMALIZED_MULTIPLY, new AggregatedSingleFeatureCreator(), new ThresholdClassifier(Math.exp(-5))); final AnomalyDetection detection = new AnomalyDetection(detector, pdfa); final ExperimentResult expected = new ExperimentResult(467, 4525, 8, 0); final ExperimentResult actual = detection.test(trainTest.getValue()); assertEquals(expected, actual);//from w w w. ja v a2s.co m assertEquals(882, pdfa.getStateCount()); }
From source file:sadl.modellearner.AlergiaTest.java
@Test public void testLoopBigRecTrebaMerge() throws URISyntaxException, IOException { final Alergia alergia = new Alergia(0.05, true, MergeMethod.TREBA); final Pair<TimedInput, TimedInput> trainTest = IoUtils .readTrainTestFile(Paths.get(this.getClass().getResource("/pdtta/smac_mix_type1.txt").toURI())); final PDFA pdfa = alergia.train(trainTest.getKey()); final AnomalyDetector detector = new VectorDetector(ProbabilityAggregationMethod.NORMALIZED_MULTIPLY, new AggregatedSingleFeatureCreator(), new ThresholdClassifier(Math.exp(-5))); final AnomalyDetection detection = new AnomalyDetection(detector, pdfa); final ExperimentResult expected = new ExperimentResult(467, 4528, 5, 0); final ExperimentResult actual = detection.test(trainTest.getValue()); assertEquals(expected, actual);/* w ww .ja v a2 s .co m*/ assertEquals(808, pdfa.getStateCount()); }
From source file:sadl.modellearner.AlergiaTest.java
@Test public void testRbBigNonRecPaperMerge() throws URISyntaxException, IOException { final AlergiaRedBlue alergia = new AlergiaRedBlue(0.05, false, MergeMethod.ALERGIA_PAPER); final Pair<TimedInput, TimedInput> trainTest = IoUtils .readTrainTestFile(Paths.get(this.getClass().getResource("/pdtta/smac_mix_type1.txt").toURI())); final PDFA pdfaAlergia = alergia.train(trainTest.getKey()); final AnomalyDetector detector = new VectorDetector(ProbabilityAggregationMethod.NORMALIZED_MULTIPLY, new AggregatedSingleFeatureCreator(), new ThresholdClassifier(Math.exp(-5))); final AnomalyDetection detection = new AnomalyDetection(detector, pdfaAlergia); final ExperimentResult expected = new ExperimentResult(0, 4533, 0, 467); final ExperimentResult actual = detection.test(trainTest.getValue()); assertEquals(expected, actual);//from w ww .j a v a2 s . c o m assertEquals(2, pdfaAlergia.getStateCount()); }
From source file:sadl.modellearner.AlergiaTest.java
@Test public void testRbBigNonRecTrebaMerge() throws URISyntaxException, IOException { final AlergiaRedBlue alergia = new AlergiaRedBlue(0.05, false, MergeMethod.TREBA); final Pair<TimedInput, TimedInput> trainTest = IoUtils .readTrainTestFile(Paths.get(this.getClass().getResource("/pdtta/smac_mix_type1.txt").toURI())); final PDFA pdfa = alergia.train(trainTest.getKey()); final AnomalyDetector detector = new VectorDetector(ProbabilityAggregationMethod.NORMALIZED_MULTIPLY, new AggregatedSingleFeatureCreator(), new ThresholdClassifier(Math.exp(-5))); final AnomalyDetection detection = new AnomalyDetection(detector, pdfa); final ExperimentResult expected = new ExperimentResult(0, 4533, 0, 467); final ExperimentResult actual = detection.test(trainTest.getValue()); assertEquals(expected, actual);/*from w ww . j a v a 2 s .c o m*/ assertEquals(2, pdfa.getStateCount()); }
From source file:sadl.modellearner.AlergiaTest.java
@Test public void testRbBigRecPaperMerge() throws URISyntaxException, IOException { final AlergiaRedBlue alergia = new AlergiaRedBlue(0.05, true, MergeMethod.ALERGIA_PAPER); final Pair<TimedInput, TimedInput> trainTest = IoUtils .readTrainTestFile(Paths.get(this.getClass().getResource("/pdtta/smac_mix_type1.txt").toURI())); final PDFA pdfaAlergia = alergia.train(trainTest.getKey()); final AnomalyDetector detector = new VectorDetector(ProbabilityAggregationMethod.NORMALIZED_MULTIPLY, new AggregatedSingleFeatureCreator(), new ThresholdClassifier(Math.exp(-5))); final AnomalyDetection detection = new AnomalyDetection(detector, pdfaAlergia); final ExperimentResult alergiaEexpected = new ExperimentResult(467, 4532, 1, 0); final ExperimentResult alergiaActual = detection.test(trainTest.getValue()); assertEquals(alergiaEexpected, alergiaActual); assertEquals(108, pdfaAlergia.getStateCount()); }
From source file:sadl.modellearner.AlergiaTest.java
@Test public void testRbBigRecTrebaMerge() throws URISyntaxException, IOException { final AlergiaRedBlue alergia = new AlergiaRedBlue(0.05, true, MergeMethod.TREBA); final Pair<TimedInput, TimedInput> trainTest = IoUtils .readTrainTestFile(Paths.get(this.getClass().getResource("/pdtta/smac_mix_type1.txt").toURI())); final PDFA pdfaAlergia = alergia.train(trainTest.getKey()); final AnomalyDetector detector = new VectorDetector(ProbabilityAggregationMethod.NORMALIZED_MULTIPLY, new AggregatedSingleFeatureCreator(), new ThresholdClassifier(Math.exp(-5))); final AnomalyDetection detection = new AnomalyDetection(detector, pdfaAlergia); final ExperimentResult expected = new ExperimentResult(467, 4532, 1, 0); final ExperimentResult actual = detection.test(trainTest.getValue()); assertEquals(expected, actual);/*ww w. ja va 2 s. c o m*/ assertEquals(70, pdfaAlergia.getStateCount()); }
From source file:sadl.modellearner.AlergiaTest.java
@Test public void testTrebaBigNonRec() throws URISyntaxException, IOException { if (LibraryChecker.trebaDepsInstalled()) { final TrebaPdfaLearner treba = new TrebaPdfaLearner(0.05, false, MergeTest.ALERGIA, 0.0, 0); final Pair<TimedInput, TimedInput> trainTest = IoUtils .readTrainTestFile(Paths.get(this.getClass().getResource("/pdtta/smac_mix_type1.txt").toURI())); final AnomalyDetector detector = new VectorDetector(ProbabilityAggregationMethod.NORMALIZED_MULTIPLY, new AggregatedSingleFeatureCreator(), new ThresholdClassifier(Math.exp(-5))); final PDFA pdfaTreba = treba.train(trainTest.getKey()); final AnomalyDetection trebaDetection = new AnomalyDetection(detector, pdfaTreba); final ExperimentResult trebaExpected = new ExperimentResult(463, 4533, 0, 4); final ExperimentResult trebaActual = trebaDetection.test(trainTest.getValue()); logger.info("Treba PDFA has {} states.", pdfaTreba.getStateCount()); assertEquals(trebaExpected, trebaActual); assertEquals(42, pdfaTreba.getStateCount()); } else {//from w ww . j a v a 2 s .c om System.out.println("Did not do any test because OS is not linux and treba cannot be loaded."); } }