MOA 12.03
Real Time Analytics for Data Streams
RunTasks.java
Go to the documentation of this file.
00001 /*
00002  *    RunTasks.java
00003  *    Copyright (C) 2011 University of Waikato, Hamilton, New Zealand
00004  *    @author Richard Kirkby (rkirkby@cs.waikato.ac.nz)
00005  *    @author Albert Bifet (abifet at cs dot waikato dot ac dot nz)
00006  *
00007  *    This program is free software; you can redistribute it and/or modify
00008  *    it under the terms of the GNU General Public License as published by
00009  *    the Free Software Foundation; either version 3 of the License, or
00010  *    (at your option) any later version.
00011  *
00012  *    This program is distributed in the hope that it will be useful,
00013  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *    GNU General Public License for more details.
00016  *
00017  *    You should have received a copy of the GNU General Public License
00018  *    along with this program. If not, see <http://www.gnu.org/licenses/>.
00019  *    
00020  */
00021 package moa.tasks;
00022 
00023 import moa.core.ObjectRepository;
00024 import moa.options.ClassOption;
00025 import moa.options.FloatOption;
00026 import moa.options.StringOption;
00027 
00035 public class RunTasks extends MainTask {
00036 
00037     @Override
00038     public String getPurposeString() {
00039         return "Runs several experiments modifying values of parameters.";
00040     }
00041 
00042     private static final long serialVersionUID = 1L;
00043 
00044     public ClassOption taskOption = new ClassOption("task", 't',
00045             "Task to do.", Task.class, "EvaluatePrequential -l ActiveClassifier -i 1000000 -d temp.txt");
00046 
00047     public StringOption classifierParameterOption = new StringOption("classifierParameter", 'p',
00048             "Classifier parameter to vary.", "b");
00049 
00050     public FloatOption firstValueOption = new FloatOption("firstValue",
00051             'f', "First value", 0.0);
00052 
00053     public FloatOption lastValueOption = new FloatOption("lastValue",
00054             'l', "Last value", 1.0);
00055 
00056     public FloatOption incrementValueOption = new FloatOption("incrementValue",
00057             'i', "Increment value", 0.1);
00058 
00059     @Override
00060     public Class<?> getTaskResultType() {
00061         return this.task.getTaskResultType();
00062     }
00063 
00064     protected Task task;
00065 
00066     @Override
00067     protected Object doMainTask(TaskMonitor monitor, ObjectRepository repository) {
00068         Object result = null;
00069 
00070         String commandString = this.taskOption.getValueAsCLIString();
00071         //for each possible value of the parameter
00072         for (double valueParameter = this.firstValueOption.getValue();
00073                 valueParameter <= this.lastValueOption.getValue();
00074                 valueParameter += this.incrementValueOption.getValue()) {
00075             //Add parameter
00076             this.task = (Task) getPreparedClassOption(this.taskOption);
00077             if (this.task instanceof EvaluatePrequential) {
00078                 String classifier = ((EvaluatePrequential) this.task).learnerOption.getValueAsCLIString();
00079                 ((EvaluatePrequential) this.task).learnerOption.setValueViaCLIString(classifier + " -" + classifierParameterOption.getValue() + " " + valueParameter);
00080             }
00081             if (this.task instanceof EvaluateInterleavedTestThenTrain) {
00082                 String classifier = ((EvaluateInterleavedTestThenTrain) this.task).learnerOption.getValueAsCLIString();
00083                 ((EvaluateInterleavedTestThenTrain) this.task).learnerOption.setValueViaCLIString(classifier + " -" + classifierParameterOption.getValue() + " " + valueParameter);
00084             }
00085             //Run task
00086             result = this.task.doTask(monitor, repository);
00087             //System.out.println(((AbstractOptionHandler) this.task).getCLICreationString(Task.class));
00088         }
00089         return result;
00090     }
00091 }
 All Classes Namespaces Files Functions Variables Enumerations