Class Simple
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- weka.classifiers.meta.socketfacade.AbstractDataPreparation
-
- weka.classifiers.meta.socketfacade.Simple
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,Serializable
public class Simple extends AbstractDataPreparation
Simple preparation scheme, using JSON with the actual data in CSV format.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description Simple()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddDatasetInfo(com.google.gson.JsonObject json, weka.core.Instances data)Information about the dataset to the JSON object.protected com.google.gson.JsonElementfromBytes(byte[] data)Turns the bytes back into a JSON object.StringglobalInfo()Returns a string describing the object.doubleparseClassify(byte[] data)Parses the data received from the process, to be returned by theClassifier.classifyInstance(Instance)method.double[]parseDistribution(byte[] data, int numClasses)Parses the data received from the process, to be returned by theClassifier.distributionForInstance(Instance)method.StringparseTrain(byte[] data)Parses the data received from the process from the training process.byte[]prepareClassify(weka.core.Instance inst, SocketFacade facade)Prepares the instance for theClassifier.classifyInstance(Instance)method.byte[]prepareDistribution(weka.core.Instance inst, SocketFacade facade)Prepares the instance for theClassifier.distributionForInstance(Instance)method.byte[]prepareTrain(weka.core.Instances data, SocketFacade facade)Prepares the data for training.protected byte[]toBytes(com.google.gson.JsonObject json)Turns the JSON object into bytes.protected StringtoCSV(weka.core.Instance inst)Turns the instance into CSV.protected StringtoCSV(weka.core.Instances data)Turns the instances into CSV.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, 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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
toBytes
protected byte[] toBytes(com.google.gson.JsonObject json)
Turns the JSON object into bytes.- Parameters:
json- the object to convert- Returns:
- the bytes
-
toCSV
protected String toCSV(weka.core.Instances data)
Turns the instances into CSV.- Parameters:
data- the instances to convert- Returns:
- the CSV string
-
toCSV
protected String toCSV(weka.core.Instance inst)
Turns the instance into CSV.- Parameters:
inst- the instance to convert- Returns:
- the CSV string
-
addDatasetInfo
protected void addDatasetInfo(com.google.gson.JsonObject json, weka.core.Instances data)Information about the dataset to the JSON object.- Parameters:
json- the json object to add todata- the dataset structure
-
prepareTrain
public byte[] prepareTrain(weka.core.Instances data, SocketFacade facade)Prepares the data for training.- Specified by:
prepareTrainin classAbstractDataPreparation- Parameters:
data- the data to usefacade- the classifier using the data preparation- Returns:
- the prepared data
-
prepareClassify
public byte[] prepareClassify(weka.core.Instance inst, SocketFacade facade)Prepares the instance for theClassifier.classifyInstance(Instance)method.- Specified by:
prepareClassifyin classAbstractDataPreparation- Parameters:
inst- the data to usefacade- the classifier using the data preparation- Returns:
- the prepared data
-
prepareDistribution
public byte[] prepareDistribution(weka.core.Instance inst, SocketFacade facade)Prepares the instance for theClassifier.distributionForInstance(Instance)method.- Specified by:
prepareDistributionin classAbstractDataPreparation- Parameters:
inst- the data to usefacade- the classifier using the data preparation- Returns:
- the prepared data
-
fromBytes
protected com.google.gson.JsonElement fromBytes(byte[] data)
Turns the bytes back into a JSON object.- Parameters:
data- the data- Returns:
- the generate JSON object
-
parseTrain
public String parseTrain(byte[] data)
Parses the data received from the process from the training process.- Specified by:
parseTrainin classAbstractDataPreparation- Parameters:
data- the data to parse- Returns:
- null if successful, otherwise error message
-
parseClassify
public double parseClassify(byte[] data)
Parses the data received from the process, to be returned by theClassifier.classifyInstance(Instance)method.- Specified by:
parseClassifyin classAbstractDataPreparation- Parameters:
data- the data to parse- Returns:
- the classification
-
parseDistribution
public double[] parseDistribution(byte[] data, int numClasses)Parses the data received from the process, to be returned by theClassifier.distributionForInstance(Instance)method.- Specified by:
parseDistributionin classAbstractDataPreparation- Parameters:
data- the data to parsenumClasses- the number of classes- Returns:
- the class distribution
-
-