public class ScikitLearnRegression extends BaseRegression implements ExternalModel
fit(X, y): Train the model given attribute matrix X,
and observation matrix y.
predict(X): Run the model
Note: This implementation requires the ability to write temporary
files on whatever system Magpie is running on.
Usage: <model> [<compression level>]
See
this tutorial for how to save Scikit-Learn objects.
| Modifier and Type | Field and Description |
|---|---|
boolean |
Debug
Whether to print output from python stdout to screen
|
protected java.lang.Process |
ScikitServer
Scikit server process
|
AttributeSelector, trained, TrainingStats, validated, ValidationStats| Constructor and Description |
|---|
ScikitLearnRegression() |
| Modifier and Type | Method and Description |
|---|---|
ScikitLearnRegression |
clone() |
void |
close() |
void |
closeServer()
Set a command to the model server that we are done with it.
|
int |
getNFittingParameters()
Number of fitting parameters in a model.
|
int |
getPort()
Get the port number for this model's server
|
java.lang.Process |
getProcess()
Get the process holding this external port
|
protected java.lang.String |
printModel_protected()
Internal method that handles printing the model as a string.
|
java.util.List<java.lang.String> |
printModelDescriptionDetails(boolean htmlFormat)
Print details of the model.
|
java.lang.String |
printUsage()
Print out required format for options.
|
void |
readModel(java.io.InputStream input)
Read model from an input stream
|
void |
run_protected(Dataset runData)
Run a model without checking if stuff is trained (use carefully)
|
boolean |
serverIsRunning()
Check whether the server is running
|
void |
setCompressionLevel(int level)
Define how well model is compressed after training.
|
void |
setOptions(java.util.List<java.lang.Object> Options)
Set any options for this object.
|
void |
startServer()
Start the server hosting the model.
|
protected void |
train_protected(Dataset TrainData)
Train a model without evaluating performance
|
void |
writeModel(java.io.OutputStream output)
Write model to output stream
|
doRobustRegression, getRobustRegressionQ, robustTraining, runCommand, setRobustRegressionQabout, crossValidate, crossValidate, crossValidate, done, externallyValidate, getAttributeSelector, getCitations, getFilter, getTrainTime, getValidationMethod, handleSetCommand, isTrained, isValidated, loadState, printCommand, printDescription, printModel, resetModel, run, saveCommand, saveState, setAttributeSelector, setComponent, setFilter, train, trainprotected transient java.lang.Process ScikitServer
public boolean Debug
public void close()
throws java.lang.Exception
close in interface java.lang.AutoCloseablejava.lang.Exceptionpublic void closeServer()
ExternalModelcloseServer in interface ExternalModelpublic ScikitLearnRegression clone()
clone in class BaseRegressionpublic void setOptions(java.util.List<java.lang.Object> Options)
throws java.lang.Exception
OptionssetOptions in interface OptionsOptions - Array of options as Objects - can be nulljava.lang.Exception - if problem with inputspublic java.lang.String printUsage()
OptionsprintUsage in interface Optionspublic int getPort()
ExternalModelgetPort in interface ExternalModelpublic void setCompressionLevel(int level)
throws java.lang.Exception
This class works by launching a server than runs a scikit-learn model. After training, this server sends back the model as a pickle file. For large datasets, this could be a huge file. This option allows one to compress it before transmission.
setCompressionLevel in interface ExternalModellevel - Desired level. 1: Fastest, 9: Smallest memory footprintjava.lang.ExceptionScikitModelpublic void readModel(java.io.InputStream input)
throws java.lang.Exception
readModel in interface ExternalModelinput - Input stream providing model datajava.io.IOExceptionjava.lang.Exceptionpublic void writeModel(java.io.OutputStream output)
throws java.io.IOException
writeModel in interface ExternalModeloutput - java.io.IOExceptionpublic void startServer()
throws java.lang.Exception
ExternalModelstartServer in interface ExternalModeljava.lang.Exceptionpublic boolean serverIsRunning()
ExternalModelserverIsRunning in interface ExternalModelpublic java.lang.Process getProcess()
ExternalModelgetProcess in interface ExternalModelprotected void train_protected(Dataset TrainData)
BaseModeltrain_protected in class BaseModelTrainData - Training datapublic void run_protected(Dataset runData)
BaseModelrun_protected in class BaseModelrunData - Training dataprotected java.lang.String printModel_protected()
BaseModelprintModel_protected in class BaseModelpublic int getNFittingParameters()
AbstractRegressionModelgetNFittingParameters in interface AbstractRegressionModelpublic java.util.List<java.lang.String> printModelDescriptionDetails(boolean htmlFormat)
BaseModelBaseModel.printDescription(boolean).
Implementation note: No not add indentation for details. That is handled
by BaseModel.printDescription(boolean). You should also call the super
operation to get the Normalizer and Attribute selector settings
printModelDescriptionDetails in class BaseModelhtmlFormat - Whether to use HTML format