adams.flow.webservice
Class SimpleWekaService

java.lang.Object
  extended by adams.core.ConsoleObject
      extended by adams.core.option.AbstractOptionHandler
          extended by adams.flow.webservice.SimpleWekaService
All Implemented Interfaces:
Debuggable, Destroyable, OptionHandler, SizeOfHandler, OwnedByWekaServiceWS, Serializable, WekaService

public class SimpleWekaService
extends AbstractOptionHandler
implements WekaService, OwnedByWekaServiceWS

Class that implements the weka web service.

Version:
$Revision$
Author:
msf8, FracPete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  LRUCache<String,Classifier> m_Classifiers
          the cache for the classifier models.
protected  LRUCache<String,weka.clusterers.Clusterer> m_Clusterers
          the cache for the clusterer models.
protected  WekaServiceWS m_Owner
          web service object
 
Fields inherited from class adams.core.option.AbstractOptionHandler
m_DebugLevel, m_OptionManager
 
Constructor Summary
SimpleWekaService()
          Default Constructor.
 
Method Summary
 CrossValidateResponseObject crossValidateClassifier(Dataset dataset, int seed, int folds, String classifier)
          Cross-validates a classifier on a dataset.
 DisplayClassifierResponseObject displayClassifier(String model)
          Returns the string representation of the specified classifier.
 DisplayClustererResponseObject displayClusterer(String model)
          Returns the string representation of the specified clusterer.
protected  void displayString(Dataset dataset)
          For outputting the dataset in debug mode.
 WekaServiceWS getOwner()
          Returns the current owner of this webservice.
 String globalInfo()
          Returns a string for the GUI that describes this object.
 List<String> listClassifiers()
          Returns a list of all classifier models currently stored on the server.
 List<String> listClusterers()
          Returns a list of all clusterer models currently stored on the server.
 OptimizeReturnObject optimizeClassifierMultiSearch(String classifier, List<String> searchParameters, Dataset dataset, String evaluation)
          Optimizes the parameters of a base classifier using MultiSearch.
 PredictClassifierResponseObject predictClassifier(Dataset dataset, String modelName)
          Makes predictions using a previously generated model.
 PredictClustererResponseObject predictClusterer(Dataset dataset, String modelName)
          Uses a previously built clusterer model to predict clusters for the provided data.
 void setOwner(WekaServiceWS value)
          Sets the owner of this webservice.
 TestClassifierResponseObject testClassifier(Dataset dataset, String modelName)
          Tests a previously trained model.
 TrainClassifierResponseObject trainClassifier(Dataset dataset, String classifier, String name)
          Performs training of a classifier and stores it in the model cache.
 TrainClustererResponseObject trainClusterer(Dataset dataset, String clusterer, String modelName)
          Trains a cluster algorithm.
 TransformResponseObject transform(Dataset dataset, String actorName)
          Transforms a dataset using a global actor on the server.
 
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, debug, debug, debugLevelTipText, defineOptions, destroy, finishInit, getDebugLevel, getOptionManager, initialize, isDebugOn, newOptionManager, reset, setDebugLevel, toCommandLine, toString
 
Methods inherited from class adams.core.ConsoleObject
getDebugging, getSystemErr, getSystemOut, sizeOf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_Owner

protected WekaServiceWS m_Owner
web service object


m_Classifiers

protected LRUCache<String,Classifier> m_Classifiers
the cache for the classifier models.


m_Clusterers

protected LRUCache<String,weka.clusterers.Clusterer> m_Clusterers
the cache for the clusterer models.

Constructor Detail

SimpleWekaService

public SimpleWekaService()
Default Constructor.

NB: the owning webservice needs to get set before using this implemention, using the setOwner(WekaServiceWS) method.

Method Detail

globalInfo

public String globalInfo()
Returns a string for the GUI that describes this object.

Specified by:
globalInfo in class AbstractOptionHandler
Returns:
the description

setOwner

public void setOwner(WekaServiceWS value)
Sets the owner of this webservice.

Specified by:
setOwner in interface OwnedByWekaServiceWS
Parameters:
value - the owner

getOwner

public WekaServiceWS getOwner()
Returns the current owner of this webservice.

Specified by:
getOwner in interface OwnedByWekaServiceWS
Returns:
the owner, null if none set

trainClassifier

public TrainClassifierResponseObject trainClassifier(Dataset dataset,
                                                     String classifier,
                                                     String name)
Performs training of a classifier and stores it in the model cache.

Specified by:
trainClassifier in interface WekaService
Parameters:
dataset - the dataset to use for training
classifier - the classifier setup
name - the identifier for the model
Returns:
null if OK, otherwise error message

testClassifier

public TestClassifierResponseObject testClassifier(Dataset dataset,
                                                   String modelName)
Tests a previously trained model.

Specified by:
testClassifier in interface WekaService
Parameters:
dataset - the dataset to use for testing
modelName - the name of the model to use
Returns:
the response

crossValidateClassifier

public CrossValidateResponseObject crossValidateClassifier(Dataset dataset,
                                                           int seed,
                                                           int folds,
                                                           String classifier)
Cross-validates a classifier on a dataset.

Specified by:
crossValidateClassifier in interface WekaService
Parameters:
dataset - the dataset to use for cross-validation
seed - the seed for randomizing the data
folds - the number of folds to use
classifier - the classifier setup
Returns:
the response

predictClassifier

public PredictClassifierResponseObject predictClassifier(Dataset dataset,
                                                         String modelName)
Makes predictions using a previously generated model.

Specified by:
predictClassifier in interface WekaService
Parameters:
dataset - the data to use for the predictions
modelName - the model to use
Returns:
the response

transform

public TransformResponseObject transform(Dataset dataset,
                                         String actorName)
Transforms a dataset using a global actor on the server.

Specified by:
transform in interface WekaService
Parameters:
dataset - the data to transform
actorName - the global actor to use
Returns:
the response with the transformed data or an error message

trainClusterer

public TrainClustererResponseObject trainClusterer(Dataset dataset,
                                                   String clusterer,
                                                   String modelName)
Trains a cluster algorithm.

Specified by:
trainClusterer in interface WekaService
Parameters:
dataset - the data to use
clusterer - the clusterer setup to use
modelName - the name to store the model under
Returns:
the response

predictClusterer

public PredictClustererResponseObject predictClusterer(Dataset dataset,
                                                       String modelName)
Uses a previously built clusterer model to predict clusters for the provided data.

Specified by:
predictClusterer in interface WekaService
Parameters:
dataset - the data to predict the clusters for
modelName - the name of the clusterer to use
Returns:
the predictions

displayClassifier

public DisplayClassifierResponseObject displayClassifier(String model)
Returns the string representation of the specified classifier.

Specified by:
displayClassifier in interface WekaService
Parameters:
model - the model name to return the string representation for
Returns:
the response

displayClusterer

public DisplayClustererResponseObject displayClusterer(String model)
Returns the string representation of the specified clusterer.

Specified by:
displayClusterer in interface WekaService
Parameters:
model - the model name to return the string representation for
Returns:
the response

listClassifiers

public List<String> listClassifiers()
Returns a list of all classifier models currently stored on the server.

Specified by:
listClassifiers in interface WekaService
Returns:
the list of classifier models

listClusterers

public List<String> listClusterers()
Returns a list of all clusterer models currently stored on the server.

Specified by:
listClusterers in interface WekaService
Returns:
the list of clusterer models

optimizeClassifierMultiSearch

public OptimizeReturnObject optimizeClassifierMultiSearch(String classifier,
                                                          List<String> searchParameters,
                                                          Dataset dataset,
                                                          String evaluation)
Optimizes the parameters of a base classifier using MultiSearch.

Specified by:
optimizeClassifierMultiSearch in interface WekaService
Parameters:
classifier - the base classifier
searchParameters - the search parameters for the optimization
dataset - the dataset to evaluate on
evaluation - the statistic to use for performance evaluation
Returns:
the result of the optimization

displayString

protected void displayString(Dataset dataset)
For outputting the dataset in debug mode.

Parameters:
dataset - the dataset to output


Copyright © 2013 University of Waikato, Hamilton, NZ. All Rights Reserved.