Package adams.data.wekapyroproxy
Class SimpleJsonCommunicationProcessor
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.wekapyroproxy.AbstractCommunicationProcessor
-
- adams.data.wekapyroproxy.SimpleJsonCommunicationProcessor
-
- 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 SimpleJsonCommunicationProcessor extends AbstractCommunicationProcessor
Turns Instances/Instance into simple JSON.
Train:{ Model:
Train: { X: [...], // single instance ... ], Y: [...] // class values } } Predict (send):
{ Model:
Train: { X: [...], // single instance } } Predict (receive):
{ Error:
Prediction: [...] // distribution array (single double for numeric class) } - Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SimpleJsonCommunicationProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
doConvertDataset(PyroProxy owner, weka.core.Instances data)
Performs the initialization.protected Object
doConvertInstance(PyroProxy owner, weka.core.Instance inst)
Converts the instance into a different format.protected void
doInitialize(PyroProxy owner, weka.core.Instances data)
Performs the initialization.protected double[]
doParsePrediction(PyroProxy owner, Object prediction)
Parses the prediction.protected double[][]
doParsePredictions(PyroProxy owner, Object predictions)
Parses the predictions.String
globalInfo()
Returns a string describing the object.protected net.minidev.json.JSONArray
instanceToRow(weka.core.Instance inst)
Converts a single Instance into a JSON array (excluding class).boolean
supportsBatchPredictions()
Returns whether batch predictions are supported.-
Methods inherited from class adams.data.wekapyroproxy.AbstractCommunicationProcessor
checkDataset, checkInitialize, checkInstance, checkPrediction, checkPredictions, convertDataset, convertInstance, initialize, parsePrediction, parsePredictions
-
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
-
doInitialize
protected void doInitialize(PyroProxy owner, weka.core.Instances data) throws Exception
Performs the initialization.- Specified by:
doInitialize
in classAbstractCommunicationProcessor
- Parameters:
owner
- the owning classifierdata
- the training data- Throws:
Exception
- if initialization fails
-
instanceToRow
protected net.minidev.json.JSONArray instanceToRow(weka.core.Instance inst)
Converts a single Instance into a JSON array (excluding class).- Parameters:
inst
- the instance to convert- Returns:
- the JSON array
-
doConvertDataset
protected Object doConvertDataset(PyroProxy owner, weka.core.Instances data) throws Exception
Performs the initialization.- Specified by:
doConvertDataset
in classAbstractCommunicationProcessor
- Parameters:
owner
- the owning classifierdata
- the training data- Returns:
- the converted dataset
- Throws:
Exception
- if initialization fails
-
doConvertInstance
protected Object doConvertInstance(PyroProxy owner, weka.core.Instance inst) throws Exception
Converts the instance into a different format.- Specified by:
doConvertInstance
in classAbstractCommunicationProcessor
- Parameters:
owner
- the owning classifierinst
- the instance to convert- Returns:
- the generated data structure
- Throws:
Exception
- if conversion fails
-
doParsePrediction
protected double[] doParsePrediction(PyroProxy owner, Object prediction) throws Exception
Parses the prediction.- Specified by:
doParsePrediction
in classAbstractCommunicationProcessor
- Parameters:
owner
- the owning classifierprediction
- the prediction to parse- Returns:
- the class distribution
- Throws:
Exception
- if conversion fails
-
supportsBatchPredictions
public boolean supportsBatchPredictions()
Returns whether batch predictions are supported.- Specified by:
supportsBatchPredictions
in classAbstractCommunicationProcessor
- Returns:
- true if supported
-
doParsePredictions
protected double[][] doParsePredictions(PyroProxy owner, Object predictions) throws Exception
Parses the predictions.- Specified by:
doParsePredictions
in classAbstractCommunicationProcessor
- Parameters:
owner
- the owning classifierpredictions
- the predictions to parse- Returns:
- the class distribution
- Throws:
Exception
- if conversion fails
-
-