Package se.hb.jcp.cli
Class IOTools
- java.lang.Object
-
- se.hb.jcp.cli.IOTools
-
public class IOTools extends java.lang.ObjectUtility functions for reading/writing data to/from JSON.- Author:
- anders.gidenstam(at)hb.se
-
-
Constructor Summary
Constructors Constructor Description IOTools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanreadInstanceFromJSON(org.json.JSONTokener instanceReader, cern.colt.matrix.DoubleMatrix1D instance)Read an instance from a JSON stream.static voidwriteAsJSON(cern.colt.matrix.DoubleMatrix1D instance, double target, org.json.JSONWriter jsonWriter)Write an instance to a JSON writer.static voidwriteAsJSON(cern.colt.matrix.DoubleMatrix1D instance, org.json.JSONWriter jsonWriter)Write an instance to a JSON writer.static voidwriteAsJSON(ConformalClassification prediction, cern.colt.matrix.DoubleMatrix1D instance, double target, org.json.JSONWriter resultWriter)Write a ConformalClassification including internal state as JSON to a JSON writer.static voidwriteAsJSON(ConformalClassification prediction, org.json.JSONWriter resultWriter)Write a ConformalClassification as JSON to a JSON writer.
-
-
-
Method Detail
-
writeAsJSON
public static void writeAsJSON(cern.colt.matrix.DoubleMatrix1D instance, org.json.JSONWriter jsonWriter)Write an instance to a JSON writer. The sparse format is: { "<attribute index>":<attribute value>, ... } and indices are 0-based.- Parameters:
instance- the instance to write.jsonWriter- the JSON writer.
-
writeAsJSON
public static void writeAsJSON(cern.colt.matrix.DoubleMatrix1D instance, double target, org.json.JSONWriter jsonWriter)Write an instance to a JSON writer. The sparse format is: { "<attribute index>":<attribute value>, ... } and indices are 0-based.- Parameters:
instance- the instance to write.target- the instance target/label.jsonWriter- the JSON writer.
-
readInstanceFromJSON
public static boolean readInstanceFromJSON(org.json.JSONTokener instanceReader, cern.colt.matrix.DoubleMatrix1D instance)Read an instance from a JSON stream. The sparse format is: { "<attribute index>":<attribute value>, ... } and indices are 0-based.- Parameters:
instanceReader- the JSON reader.instance- the instance to read into.- Returns:
- true if an instance was successfully read; false otherwise.
-
writeAsJSON
public static void writeAsJSON(ConformalClassification prediction, org.json.JSONWriter resultWriter)
Write a ConformalClassification as JSON to a JSON writer. The format is: { "p-values":{["<label>":<p-value>]*}, "point-prediction":{"label":<label>, "confidence":<confidence>, "credibility":<credibility>} }.- Parameters:
prediction- the prediction to write.resultWriter- the JSON writer.
-
writeAsJSON
public static void writeAsJSON(ConformalClassification prediction, cern.colt.matrix.DoubleMatrix1D instance, double target, org.json.JSONWriter resultWriter)
Write a ConformalClassification including internal state as JSON to a JSON writer. The format is: { "p-values":{["<label>":<p-value>]*}, "point-prediction":{"label":<label>, "confidence":<confidence>, "credibility":<credibility>}, "true-label":<label>, "nc-scores":{ ["<label>":<nc-score>]* } }.- Parameters:
prediction- the prediction to write.instance- the instance.target- the instance target/label.resultWriter- the JSON writer.
-
-