public class ScikitLearnRegression extends BaseRegression
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 |
---|---|
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() |
protected void |
finalize() |
int |
getNFittingParameters()
Number of fitting parameters in a model.
|
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 TrainData)
Run a model without checking if stuff is trained (use carefully)
|
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.
|
protected void |
startScikitServer()
Start the server hosting the Scikit model.
|
protected void |
train_protected(Dataset TrainData)
Train a model without evaluating performance
|
void |
writeModel(java.lang.String path)
Write stored model to disk.
|
doRobustRegression, getRobustRegressionQ, robustTraining, runCommand, setRobustRegressionQ
about, crossValidate, externallyValidate, getAttributeSelector, getCitations, getFilter, getTrainTime, getValidationMethod, handleSetCommand, isTrained, isValidated, loadState, printCommand, printDescription, printModel, resetModel, run, saveCommand, saveState, setAttributeSelector, setComponent, setFilter, train, train
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public ScikitLearnRegression clone()
clone
in class BaseRegression
public void setOptions(java.util.List<java.lang.Object> Options) throws java.lang.Exception
Options
Options
- Array of options as Objects - can be null
java.lang.Exception
- if problem with inputspublic java.lang.String printUsage()
Options
public 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.
level
- Desired level. 1: Fastest, 9: Smallest memory footprintjava.lang.Exception
ScikitModel
public void readModel(java.io.InputStream input) throws java.lang.Exception
input
- Input stream providing model datajava.io.IOException
java.lang.Exception
public void writeModel(java.lang.String path) throws java.io.IOException
path
- Path to desired output filejava.io.IOException
protected void startScikitServer() throws java.lang.Exception
java.lang.Exception
protected void train_protected(Dataset TrainData)
BaseModel
train_protected
in class BaseModel
TrainData
- Training datapublic void run_protected(Dataset TrainData)
BaseModel
run_protected
in class BaseModel
TrainData
- Training datapublic int getNFittingParameters()
AbstractRegressionModel
protected java.lang.String printModel_protected()
BaseModel
printModel_protected
in class BaseModel
public java.util.List<java.lang.String> printModelDescriptionDetails(boolean htmlFormat)
BaseModel
BaseModel.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 BaseModel
htmlFormat
- Whether to use HTML format