MOA 12.03
Real Time Analytics for Data Streams
EvaluateClustering.java
Go to the documentation of this file.
00001 /*
00002  *    EvaluateClustering.java
00003  *    Copyright (C) 2009 University of Waikato, Hamilton, New Zealand
00004  *    @author Albert Bifet (abifet@cs.waikato.ac.nz)
00005  *
00006  *    This program is free software; you can redistribute it and/or modify
00007  *    it under the terms of the GNU General Public License as published by
00008  *    the Free Software Foundation; either version 3 of the License, or
00009  *    (at your option) any later version.
00010  *
00011  *    This program is distributed in the hope that it will be useful,
00012  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *    GNU General Public License for more details.
00015  *
00016  *    You should have received a copy of the GNU General Public License
00017  *    along with this program. If not, see <http://www.gnu.org/licenses/>.
00018  *    
00019  */
00020 package moa.tasks;
00021 
00022 import moa.core.ObjectRepository;
00023 import moa.evaluation.LearningCurve;
00024 import moa.options.ClassOption;
00025 import moa.options.FileOption;
00026 import moa.options.IntOption;
00027 import moa.gui.BatchCmd;
00028 import moa.clusterers.AbstractClusterer;
00029 import moa.streams.clustering.RandomRBFGeneratorEvents;
00030 
00037 public class EvaluateClustering extends MainTask {
00038 
00039     @Override
00040     public String getPurposeString() {
00041         return "Evaluates a clusterer on a stream.";
00042     }
00043 
00044     private static final long serialVersionUID = 1L;
00045 
00046     public ClassOption learnerOption = new ClassOption("learner", 'l',
00047             "Clusterer to train.", AbstractClusterer.class, "clustream.Clustream");
00048 
00049     public ClassOption streamOption = new ClassOption("stream", 's',
00050             "Stream to learn from.", RandomRBFGeneratorEvents.class,
00051             "RandomRBFGeneratorEvents");
00052 
00053     public IntOption instanceLimitOption = new IntOption("instanceLimit", 'i',
00054             "Maximum number of instances to test/train on  (-1 = no limit).",
00055             100000, -1, Integer.MAX_VALUE);
00056 
00057     public IntOption measureCollectionTypeOption = new IntOption(
00058             "measureCollectionType", 'm',
00059             "Type of measure collection", 0, 0,
00060             Integer.MAX_VALUE);
00061 
00062     /*public ClassOption evaluatorOption = new ClassOption("evaluator", 'e',
00063     "Performance evaluation method.",
00064     LearningPerformanceEvaluator.class,
00065     "BasicClusteringPerformanceEvaluator");*/
00066 
00067     /*public IntOption timeLimitOption = new IntOption("timeLimit", 't',
00068     "Maximum number of seconds to test/train for (-1 = no limit).", -1,
00069     -1, Integer.MAX_VALUE);
00070 
00071     public IntOption sampleFrequencyOption = new IntOption("sampleFrequency",
00072     'f',
00073     "How many instances between samples of the learning performance.",
00074     100000, 0, Integer.MAX_VALUE);
00075 
00076     public IntOption maxMemoryOption = new IntOption("maxMemory", 'b',
00077     "Maximum size of model (in bytes). -1 = no limit.", -1, -1,
00078     Integer.MAX_VALUE);
00079 
00080     public IntOption memCheckFrequencyOption = new IntOption(
00081     "memCheckFrequency", 'q',
00082     "How many instances between memory bound checks.", 100000, 0,
00083     Integer.MAX_VALUE);*/
00084     public FileOption dumpFileOption = new FileOption("dumpFile", 'd',
00085             "File to append intermediate csv reslts to.", "outputClustering.csv", "csv", true);
00086 
00087     @Override
00088     public Class<?> getTaskResultType() {
00089         return LearningCurve.class;
00090     }
00091 
00092     @Override
00093     protected Object doMainTask(TaskMonitor monitor, ObjectRepository repository) {
00094 
00095         BatchCmd.runBatch((RandomRBFGeneratorEvents) getPreparedClassOption(this.streamOption),
00096                 (AbstractClusterer) getPreparedClassOption(this.learnerOption),
00097                 (int) measureCollectionTypeOption.getValue(),
00098                 (int) this.instanceLimitOption.getValue(),
00099                 (String) dumpFileOption.getValue());
00100 
00101         LearningCurve learningCurve = new LearningCurve(
00102                 "learning evaluation instances");
00103         //System.out.println(learner.toString());
00104         return learningCurve;
00105     }
00106 }
 All Classes Namespaces Files Functions Variables Enumerations