Package adams.flow.webservice.meka
Class SimpleMekaService
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.webservice.meka.SimpleMekaService
-
- All Implemented Interfaces:
adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.SizeOfHandler
,OwnedByMekaServiceWS
,Serializable
,MekaService
public class SimpleMekaService extends adams.core.option.AbstractOptionHandler implements MekaService, OwnedByMekaServiceWS
Class that implements the meka web service.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected MekaServiceWS
m_Owner
web service objectprotected adams.flow.control.StorageName
m_StorageName
the name of the lookup table in the internal storage.
-
Constructor Summary
Constructors Constructor Description SimpleMekaService()
Default Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CrossValidateResponseObject
crossValidateClassifier(Dataset dataset, int seed, int folds, String classifier)
Cross-validates a classifier on a dataset.void
defineOptions()
Adds options to the internal list of options.DisplayClassifierResponseObject
displayClassifier(String model)
Returns the string representation of the specified classifier.protected void
displayString(Dataset dataset)
For outputting the dataset in debug mode.DownloadClassifierResponseObject
downloadClassifier(String modelName)
Downloads a previously generated model.MekaServiceWS
getOwner()
Returns the current owner of this webservice.adams.flow.control.StorageName
getStorageName()
Returns the name for the lookup table in the internal storage.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.PredictClassifierResponseObject
predictClassifier(Dataset dataset, String modelName)
Makes predictions using a previously generated model.protected meka.classifiers.multilabel.MultiLabelClassifier
retrieve(String name)
Retrieves the classifier from storage.void
setOwner(MekaServiceWS value)
Sets the owner of this webservice.void
setStorageName(adams.flow.control.StorageName value)
Sets the name for the lookup table in the internal storage.String
storageNameTipText()
Returns the tip text for this property.protected void
store(String name, meka.classifiers.multilabel.MultiLabelClassifier cls)
Stores the classifier in internal storage.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.TransformResponseObject
transform(Dataset dataset, String actorName)
Transforms a dataset using a callable actor on the server.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Owner
protected MekaServiceWS m_Owner
web service object
-
m_StorageName
protected adams.flow.control.StorageName m_StorageName
the name of the lookup table in the internal storage.
-
-
Constructor Detail
-
SimpleMekaService
public SimpleMekaService()
Default Constructor.
NB: the owning webservice needs to get set before using this implemention, using thesetOwner(MekaServiceWS)
method.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string for the GUI that describes this object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.core.option.AbstractOptionHandler
- Returns:
- the description
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.core.option.AbstractOptionHandler
-
setStorageName
public void setStorageName(adams.flow.control.StorageName value)
Sets the name for the lookup table in the internal storage.- Parameters:
value
- the name
-
getStorageName
public adams.flow.control.StorageName getStorageName()
Returns the name for the lookup table in the internal storage.- Returns:
- the name
-
storageNameTipText
public String storageNameTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setOwner
public void setOwner(MekaServiceWS value)
Sets the owner of this webservice.- Specified by:
setOwner
in interfaceOwnedByMekaServiceWS
- Parameters:
value
- the owner
-
getOwner
public MekaServiceWS getOwner()
Returns the current owner of this webservice.- Specified by:
getOwner
in interfaceOwnedByMekaServiceWS
- Returns:
- the owner, null if none set
-
store
protected void store(String name, meka.classifiers.multilabel.MultiLabelClassifier cls)
Stores the classifier in internal storage.- Parameters:
name
- the name of the classifiercls
- the classifier
-
retrieve
protected meka.classifiers.multilabel.MultiLabelClassifier retrieve(String name)
Retrieves the classifier from storage.- Parameters:
name
- the name of the classifier- Returns:
- the classifier, null if not found
-
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 interfaceMekaService
- Parameters:
dataset
- the dataset to use for trainingclassifier
- the classifier setupname
- 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 interfaceMekaService
- Parameters:
dataset
- the dataset to use for testingmodelName
- 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 interfaceMekaService
- Parameters:
dataset
- the dataset to use for cross-validationseed
- the seed for randomizing the datafolds
- the number of folds to useclassifier
- 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 interfaceMekaService
- Parameters:
dataset
- the data to use for the predictionsmodelName
- the model to use- Returns:
- the response
-
downloadClassifier
public DownloadClassifierResponseObject downloadClassifier(String modelName)
Downloads a previously generated model.- Specified by:
downloadClassifier
in interfaceMekaService
- Parameters:
modelName
- the model to download- Returns:
- the response
-
transform
public TransformResponseObject transform(Dataset dataset, String actorName)
Transforms a dataset using a callable actor on the server.- Specified by:
transform
in interfaceMekaService
- Parameters:
dataset
- the data to transformactorName
- the callable actor to use- Returns:
- the response with the transformed data or an error message
-
displayClassifier
public DisplayClassifierResponseObject displayClassifier(String model)
Returns the string representation of the specified classifier.- Specified by:
displayClassifier
in interfaceMekaService
- 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 interfaceMekaService
- Returns:
- the list of classifier models
-
displayString
protected void displayString(Dataset dataset)
For outputting the dataset in debug mode.- Parameters:
dataset
- the dataset to output
-
-