Package weka.core.json
Class JSONInstances
java.lang.Object
weka.core.json.JSONInstances
Class for transforming Instances objects into JSON
objects and vice versa. Missing values get stored as "?".
- Version:
- $Revision: 9664 $
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringthe attributes object.static final Stringthe class attribute indicator.static final Stringthe data section.static final Stringthe dateformat attribute.static final Stringthe header section.static final Stringthe labels attribute.static final Stringthe missing value indicator.static final Stringthe name attribute.static final Stringthe relation name.static final Stringthe sparse attribute.static final Stringthe separator for index/value in case of sparse instances.static final Stringthe type attribute.static final Stringthe values attribute.static final Stringthe weight attribute. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidFor testing only.static InstancesTurns a JSON object, if possible, into an Instances object (only header).static InstancestoInstances(JSONNode json) Turns a JSON object, if possible, into an Instances object.static JSONNodeTurns the Instances object into a JSON object.
-
Field Details
-
HEADER
the header section.- See Also:
-
DATA
the data section.- See Also:
-
RELATION
the relation name.- See Also:
-
ATTRIBUTES
the attributes object.- See Also:
-
NAME
the name attribute.- See Also:
-
TYPE
the type attribute.- See Also:
-
CLASS
the class attribute indicator.- See Also:
-
LABELS
the labels attribute.- See Also:
-
WEIGHT
the weight attribute.- See Also:
-
DATEFORMAT
the dateformat attribute.- See Also:
-
SPARSE
the sparse attribute.- See Also:
-
VALUES
the values attribute.- See Also:
-
SPARSE_SEPARATOR
the separator for index/value in case of sparse instances.- See Also:
-
MISSING_VALUE
the missing value indicator.- See Also:
-
-
Constructor Details
-
JSONInstances
public JSONInstances()
-
-
Method Details
-
toInstances
Turns a JSON object, if possible, into an Instances object.- Parameters:
json- the JSON object to convert- Returns:
- the generated Instances object, null if not possible
-
toHeader
Turns a JSON object, if possible, into an Instances object (only header).- Parameters:
json- the JSON object to convert- Returns:
- the generated Instances header object, null if not possible
-
toJSON
Turns the Instances object into a JSON object.- Parameters:
inst- the Instances to turn into a JSON object- Returns:
- the JSON object
-
main
For testing only.- Parameters:
args- expects a dataset as first parameter- Throws:
Exception- if something goes wrong
-