Package adams.data.wekapyroproxy
Class FusionJsonCommunicationProcessor
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.wekapyroproxy.AbstractCommunicationProcessor
-
- adams.data.wekapyroproxy.FusionJsonCommunicationProcessor
-
- 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 FusionJsonCommunicationProcessor extends AbstractCommunicationProcessor
Turns Instances/Instance into fusion JSON.
Train:{ "names": [
// the model name ] "inputs": { "input1": [ [...], // single instance or class value ... ] ..., "input2": [ [...], // single instance or class value ... ] ..., ] } } Predict (send):
{ "names": [
// the model name ] "inputs": { "input1": [ [...], // single instance ... ] ..., "input2": [ [...], // single instance ... ] ..., ] } } Predict (receive):
{ "error":
"outputs": { " ": { "output1": [ [...], // single prediction ... ], } } } - Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_ClassAttName
the class attribute name.protected Map<adams.core.base.BaseString,gnu.trove.list.TIntList>
m_Mapping
the mapping between fusion subset names and attribute indices.protected adams.core.base.BaseString[]
m_Names
the names for the fusion subsets.protected adams.core.base.BaseRegExp[]
m_RegExps
the regular expressions to identify fusion subsets.
-
Constructor Summary
Constructors Constructor Description FusionJsonCommunicationProcessor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.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.adams.core.base.BaseString[]
getNames()
Returns the names to use for the fusion subsets (corresponds to the subsets).adams.core.base.BaseRegExp[]
getRegExps()
Returns the regular expression to apply to the attribute names for identifying the fusion subsets (incl class).String
globalInfo()
Returns a string describing the object.protected net.minidev.json.JSONArray
instanceToRow(weka.core.Instance inst, adams.core.base.BaseString name)
Converts a single Instance into a JSON array.String
namesTipText()
Returns the tip text for this property.String
regExpsTipText()
Returns the tip text for this property.void
setNames(adams.core.base.BaseString[] value)
Sets the names to use for the fusion subsets (corresponds to the subsets).void
setRegExps(adams.core.base.BaseRegExp[] value)
Sets the regular expression to apply to the attribute names for identifying the fusion subsets (incl 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, 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_RegExps
protected adams.core.base.BaseRegExp[] m_RegExps
the regular expressions to identify fusion subsets.
-
m_Names
protected adams.core.base.BaseString[] m_Names
the names for the fusion subsets.
-
m_Mapping
protected Map<adams.core.base.BaseString,gnu.trove.list.TIntList> m_Mapping
the mapping between fusion subset names and attribute indices.
-
m_ClassAttName
protected String m_ClassAttName
the class attribute name.
-
-
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
-
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
-
setRegExps
public void setRegExps(adams.core.base.BaseRegExp[] value)
Sets the regular expression to apply to the attribute names for identifying the fusion subsets (incl class).- Parameters:
value
- the expressions
-
getRegExps
public adams.core.base.BaseRegExp[] getRegExps()
Returns the regular expression to apply to the attribute names for identifying the fusion subsets (incl class).- Returns:
- the expressions
-
regExpsTipText
public String regExpsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setNames
public void setNames(adams.core.base.BaseString[] value)
Sets the names to use for the fusion subsets (corresponds to the subsets).- Parameters:
value
- the names
-
getNames
public adams.core.base.BaseString[] getNames()
Returns the names to use for the fusion subsets (corresponds to the subsets).- Returns:
- the names
-
namesTipText
public String namesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
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, adams.core.base.BaseString name)
Converts a single Instance into a JSON array.- Parameters:
inst
- the instance to convertname
- the name of the mapping- 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
-
-