public abstract class ModelMojoReader<M extends MojoModel>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected M |
_model |
protected MojoReaderBackend |
_reader |
| Constructor and Description |
|---|
ModelMojoReader() |
| Modifier and Type | Method and Description |
|---|---|
static LinkFunctionType |
defaultLinkFunction(DistributionFamily family) |
protected boolean |
exists(java.lang.String name) |
abstract java.lang.String |
getModelName() |
protected MojoReaderBackend |
getMojoReaderBackend() |
protected abstract M |
makeModel(java.lang.String[] columns,
java.lang.String[][] domains,
java.lang.String responseColumn) |
protected M |
makeModel(java.lang.String[] columns,
java.lang.String[][] domains,
java.lang.String responseColumn,
java.lang.String treatmentColumn) |
abstract java.lang.String |
mojoVersion()
Maximal version of the mojo file current model reader supports.
|
protected byte[] |
readblob(java.lang.String name)
Retrieve binary data previously saved to the mojo file using `writeblob(key, blob)`.
|
static MojoModel |
readFrom(MojoReaderBackend reader)
|
static MojoModel |
readFrom(MojoReaderBackend reader,
boolean readModelMetadata)
|
protected IsotonicCalibrator |
readIsotonicCalibrator() |
protected <T> T |
readkv(java.lang.String key)
Retrieve value from the model's kv store which was previously put there using `writekv(key, value)`.
|
protected <T> T |
readkv(java.lang.String key,
T defVal)
Retrieves the value associated with a given key.
|
static LinkFunctionType |
readLinkFunction(java.lang.String linkFunctionTypeName,
DistributionFamily family) |
protected abstract void |
readModelData() |
protected ModelAttributes |
readModelSpecificAttributes() |
protected double[][] |
readRectangularDoubleArray(java.lang.String title)
Reads an two dimensional array written by
hex.ModelMojoWriter#writeRectangularDoubleArray method
Dimensions of the array are read from the mojo. |
protected double[][] |
readRectangularDoubleArray(java.lang.String title,
int firstSize,
int secondSize)
Reads an two dimensional array written by
hex.ModelMojoWriter#writeRectangularDoubleArray method. |
protected Table[] |
readReproducibilityInformation() |
protected java.lang.String[] |
readStringArray(java.lang.String name,
int size) |
java.lang.String[] |
readStringArrays(int aSize,
java.lang.String title) |
protected java.lang.Iterable<java.lang.String> |
readtext(java.lang.String name)
Retrieve text previously saved using `startWritingTextFile` + `writeln` as an array of lines.
|
protected java.lang.Iterable<java.lang.String> |
readtext(java.lang.String name,
boolean unescapeNewlines)
Retrieve text previously saved using `startWritingTextFile` + `writeln` as an array of lines.
|
protected MojoReaderBackend _reader
public static MojoModel readFrom(MojoReaderBackend reader) throws java.io.IOException
MojoModel, creating an instance of MojoModel useful for scoring
and model evaluation.reader - An instance of MojoReaderBackend to read from existing MOJO. After the model is de-serialized,
the MojoReaderBackend instance is automatically closed if it implements Closeable.MojoModeljava.io.IOException - Whenever there is an error reading the MojoModel's data.public static MojoModel readFrom(MojoReaderBackend reader, boolean readModelMetadata) throws java.io.IOException
MojoModel, creating an instance of MojoModel useful for scoring
and model evaluation.reader - An instance of MojoReaderBackend to read from existing MOJOreadModelMetadata - If true, parses also model metadata (model performance metrics... ModelAttributes)
Model metadata are not required for scoring, it is advised to leave this option disabled
if you want to use MOJO for inference only.MojoModeljava.io.IOException - Whenever there is an error reading the MojoModel's data.public abstract java.lang.String getModelName()
protected abstract void readModelData()
throws java.io.IOException
java.io.IOExceptionprotected abstract M makeModel(java.lang.String[] columns, java.lang.String[][] domains, java.lang.String responseColumn)
protected M makeModel(java.lang.String[] columns, java.lang.String[][] domains, java.lang.String responseColumn, java.lang.String treatmentColumn)
public abstract java.lang.String mojoVersion()
major.minor
format, where minor is a 2-digit number. For example "1.00",
"2.05", "2.13". See README in mojoland repository for more details.protected <T> T readkv(java.lang.String key)
ParseUtils.tryParse(String, Object), which occasionally may get
the answer wrong.
If the `key` is missing in the local kv store, null will be returned. However when assigning to a primitive type
this would result in an NPE, so beware.protected <T> T readkv(java.lang.String key,
T defVal)
readkv(String). If default value is not null it's type
is used to assist the parser to determine the return type.T - return typekey - name of the keydefVal - default valueprotected byte[] readblob(java.lang.String name)
throws java.io.IOException
java.io.IOExceptionprotected boolean exists(java.lang.String name)
protected java.lang.Iterable<java.lang.String> readtext(java.lang.String name)
throws java.io.IOException
java.io.IOExceptionprotected java.lang.Iterable<java.lang.String> readtext(java.lang.String name,
boolean unescapeNewlines)
throws java.io.IOException
java.io.IOExceptionprotected java.lang.String[] readStringArray(java.lang.String name,
int size)
throws java.io.IOException
java.io.IOExceptionprotected IsotonicCalibrator readIsotonicCalibrator() throws java.io.IOException
java.io.IOExceptionprotected double[][] readRectangularDoubleArray(java.lang.String title,
int firstSize,
int secondSize)
throws java.io.IOException
hex.ModelMojoWriter#writeRectangularDoubleArray method.
Dimensions of the result are explicitly given as parameters.title - can't be nullfirstSize - secondSize - java.io.IOExceptionprotected double[][] readRectangularDoubleArray(java.lang.String title)
throws java.io.IOException
hex.ModelMojoWriter#writeRectangularDoubleArray method
Dimensions of the array are read from the mojo.title - can't be nulljava.io.IOExceptionprotected Table[] readReproducibilityInformation()
protected ModelAttributes readModelSpecificAttributes()
public static LinkFunctionType readLinkFunction(java.lang.String linkFunctionTypeName, DistributionFamily family)
public static LinkFunctionType defaultLinkFunction(DistributionFamily family)
protected MojoReaderBackend getMojoReaderBackend()
public java.lang.String[] readStringArrays(int aSize,
java.lang.String title)
throws java.io.IOException
java.io.IOException