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:
adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.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
-
-
Constructor Summary
Constructors Constructor Description Simple()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addDatasetInfo(com.google.gson.JsonObject json, weka.core.Instances data)
Information about the dataset to the JSON object.protected com.google.gson.JsonElement
fromBytes(byte[] data)
Turns the bytes back into a JSON object.String
globalInfo()
Returns a string describing the object.double
parseClassify(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.String
parseTrain(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 String
toCSV(weka.core.Instance inst)
Turns the instance into CSV.protected String
toCSV(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
-
-
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.core.option.AbstractOptionHandler
- 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:
prepareTrain
in 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:
prepareClassify
in 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:
prepareDistribution
in 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:
parseTrain
in 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:
parseClassify
in 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:
parseDistribution
in classAbstractDataPreparation
- Parameters:
data
- the data to parsenumClasses
- the number of classes- Returns:
- the class distribution
-
-