source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDtrainPPM.java @ 251

Last change on this file since 251 was 184, checked in by sherbold, 13 years ago
  • refactored commands for the training of models (trainDFA, trainMarkovModel, trainPPM) by extracting one common abstract superclass

+ added command updateModel for model reinforcement

File size: 1.7 KB
Line 
1package de.ugoe.cs.eventbench.commands;
2
3import java.util.List;
4import java.util.Random;
5
6import de.ugoe.cs.eventbench.models.PredictionByPartialMatch;
7import de.ugoe.cs.eventbench.models.TrieBasedModel;
8import de.ugoe.cs.util.console.Console;
9
10/**
11 * <p>
12 * Command that trains Prediction by Partial Match (PPM) models.
13 * </p>
14 *
15 * @author Steffen Herbold
16 * @version 2.0
17 */
18public class CMDtrainPPM extends AbstractTrainCommand {
19
20        /**
21         * <p>
22         * Escape probability of the PPM model.
23         * </p>
24         */
25        double probEscape;
26
27        /**
28         * <p>
29         * Maximal Markov order of the PPM model.
30         * </p>
31         */
32        int maxOrder;
33
34        /**
35         * <p>
36         * Minimal Markov order of the PPM model. Default: 0
37         * </p>
38         */
39        int minOrder = 0;
40
41        /*
42         * (non-Javadoc)
43         *
44         * @see de.ugoe.cs.util.console.Command#help()
45         */
46        @Override
47        public void help() {
48                Console.println("Usage: trainPPM <modelName> <sequencesName> <probEscape> <maxOrder> {<minOrder>}");
49        }
50
51        /**
52         * <p>
53         * Handles the parameters probEscape, maxOrder, and minOrder.
54         * </p>
55         *
56         * @see de.ugoe.cs.eventbench.commands.AbstractTrainCommand#handleOptionalParameters(java.util.List)
57         */
58        @Override
59        void handleAdditionalParameters(List<Object> parameters) throws Exception {
60                probEscape = Double.parseDouble((String) parameters.get(2));
61                maxOrder = Integer.parseInt((String) parameters.get(3));
62                if (parameters.size() == 5) {
63                        minOrder = Integer.parseInt((String) parameters.get(4));
64                }
65        }
66
67        /*
68         * (non-Javadoc)
69         *
70         * @see de.ugoe.cs.eventbench.commands.AbstractTrainCommand#createModel()
71         */
72        @Override
73        TrieBasedModel createModel() {
74                return new PredictionByPartialMatch(maxOrder, minOrder, new Random(),
75                                probEscape);
76        }
77
78}
Note: See TracBrowser for help on using the repository browser.