public class ExternalModelUtility
extends java.lang.Object
Assumes that...
Constructor and Description |
---|
ExternalModelUtility() |
Modifier and Type | Method and Description |
---|---|
static java.util.List<java.lang.String> |
getModelDescription(ExternalModel model)
Generate a description of the model
|
static int |
initializeServer(ExternalModel model,
boolean debug)
Assuming that a model server is already launched, get the port number
and send the model object stream to the standard input of the server process.
|
static boolean |
isRunning(java.lang.Process process)
Check whether a process is running
|
static void |
runModel(ExternalModel model,
Dataset runData)
Connect to server and run model
|
static void |
startReader(java.io.InputStream processStream,
java.io.OutputStream outputStream)
Launch a thread that does nothing but read from the output of another process.
|
static void |
stopServer(ExternalModel model)
Send the "exit" command and stop a server
|
static void |
trainModel(ExternalModel model,
Dataset trainData)
Make a call to the model server to train a model
|
public static void startReader(java.io.InputStream processStream, java.io.OutputStream outputStream)
Optionally, it can also write this data to another stream
processStream
- Stream to be read fromoutputStream
- Stream to be written to. Put "null" for no outputpublic static boolean isRunning(java.lang.Process process)
process
- Processpublic static int initializeServer(ExternalModel model, boolean debug) throws java.lang.Exception
model
- Model being operated ondebug
- Whether to print standard out, or ignore itjava.lang.Exception
public static void trainModel(ExternalModel model, Dataset trainData) throws java.lang.Exception
model
- Model object being trainedtrainData
- Data used to train modeljava.io.IOException
java.lang.Exception
java.lang.IllegalArgumentException
public static void runModel(ExternalModel model, Dataset runData) throws java.lang.Exception
model
- Model to be runrunData
- Dataset to be runjava.lang.Exception
public static java.util.List<java.lang.String> getModelDescription(ExternalModel model) throws java.lang.Error
model
- Model to be accessedjava.lang.Error
public static void stopServer(ExternalModel model)
model
- Model server to be shut down