public abstract class ModelSearch extends Object implements Classifier, Regressor
Modifier and Type | Field and Description |
---|---|
protected Classifier |
baseClassifier |
protected Regressor |
baseRegressor |
protected ClassificationScore |
classificationTargetScore |
protected int |
folds
The number of CV folds
|
protected RegressionScore |
regressionTargetScore |
protected boolean |
reuseSameCVFolds
If true, create the CV splits once and re-use them for all parameters
|
protected List<Parameter> |
searchParams
The list of parameters we will search for, currently only Int and Double
params should be used
|
protected Classifier |
trainedClassifier |
protected Regressor |
trainedRegressor |
protected boolean |
trainFinalModel
If true, trains the final model on the parameters used
|
protected boolean |
trainModelsInParallel
If true, parallelism will be obtained by training the models in parallel.
|
Constructor and Description |
---|
ModelSearch(Classifier baseClassifier,
int folds) |
ModelSearch(ModelSearch toCopy)
Copy constructor
|
ModelSearch(Regressor baseRegressor,
int folds) |
Modifier and Type | Method and Description |
---|---|
CategoricalResults |
classify(DataPoint data)
Performs classification on the given data point.
|
abstract ModelSearch |
clone() |
Classifier |
getBaseClassifier()
Returns the base classifier that was originally passed in when
constructing this GridSearch.
|
Regressor |
getBaseRegressor()
Returns the base regressor that was originally passed in when
constructing this GridSearch.
|
ClassificationScore |
getClassificationTargetScore()
Returns the classification score that is trying to be optimized via grid
search
|
protected Parameter |
getParameterByName(String name)
Finds the parameter object with the given name, or throws an exception if
a parameter with the given name does not exist.
|
RegressionScore |
getRegressionTargetScore()
Returns the regression score that is trying to be optimized via grid
search
|
Classifier |
getTrainedClassifier()
Returns the resultant classifier trained on the whole data set after
performing parameter tuning.
|
Regressor |
getTrainedRegressor()
Returns the resultant regressor trained on the whole data set after
performing parameter tuning.
|
boolean |
isReuseSameCVFolds() |
boolean |
isTrainFinalModel() |
boolean |
isTrainModelsInParallel() |
double |
regress(DataPoint data) |
void |
setClassificationTargetScore(ClassificationScore classifierTargetScore)
Sets the score to attempt to optimize when performing grid search on a
classification problem.
|
void |
setRegressionTargetScore(RegressionScore regressionTargetScore)
Sets the score to attempt to optimize when performing grid search on a
regression problem.
|
void |
setReuseSameCVFolds(boolean reuseSameSplit)
Sets whether or not one set of CV folds is created and re used for every
parameter combination (the default), or if a difference set of CV folds
will be used for every parameter combination.
|
void |
setTrainFinalModel(boolean trainFinalModel)
If
true (the default) the model that was found to be best is
trained on the whole data set at the end. |
void |
setTrainModelsInParallel(boolean trainInParallel)
When set to
true (the default) parallelism is obtained by
training as many models in parallel as possible. |
boolean |
supportsWeightedData()
Indicates whether the model knows how to train using weighted data points.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
trainC, trainC
protected Classifier baseClassifier
protected Classifier trainedClassifier
protected ClassificationScore classificationTargetScore
protected RegressionScore regressionTargetScore
protected Regressor baseRegressor
protected Regressor trainedRegressor
protected List<Parameter> searchParams
protected int folds
protected boolean trainModelsInParallel
protected boolean trainFinalModel
protected boolean reuseSameCVFolds
public ModelSearch(Regressor baseRegressor, int folds)
public ModelSearch(Classifier baseClassifier, int folds)
public ModelSearch(ModelSearch toCopy)
toCopy
- the object to copypublic void setTrainModelsInParallel(boolean trainInParallel)
true
(the default) parallelism is obtained by
training as many models in parallel as possible. If false
,
parallelsm will be obtained by training the model using the Classifier.trainC(jsat.classifiers.ClassificationDataSet, java.util.concurrent.ExecutorService)
and Regressor.train(jsat.regression.RegressionDataSet, java.util.concurrent.ExecutorService)
methods.warms starts
,
parallelism obtained by training the models in parallel is intrinsically
reduced, as a model can not be warms started until another model has
finished. In the case that one of the parameters is annotated as a
warm paramter
, that parameter will be
the one rained sequential, and for every other parameter combination
models will be trained in parallel. If there is no warm parameter, the
first parameter added will be used for warm training. If there is only
one parameter and warm training is occurring, no parallelism will be
obtained.trainInParallel
- true
to get parallelism from training many
models at the same time, false
to get parallelism from getting
the model's implicit parallelism.public boolean isTrainModelsInParallel()
true
if parallelism is obtained from training many models
at the same time, false
if parallelism is obtained from using the
model's implicit parallelism.public void setTrainFinalModel(boolean trainFinalModel)
true
(the default) the model that was found to be best is
trained on the whole data set at the end. If false
, the final
model will not be trained. This means that this Object will not be usable
for predictoin. This should only be set if you know you will not be using
this model but only want to get the information about which parameter
combination is best.trainFinalModel
- true
to train the final model after grid
search, false
to not do that.public boolean isTrainFinalModel()
true
to train the final model after grid search,
false
to not do that.public void setReuseSameCVFolds(boolean reuseSameSplit)
reuseSameSplit
- true
if the same split is re-used for every
combination, false
if a new CV set is used for every parameter
combination.public boolean isReuseSameCVFolds()
true
if the same split is re-used for every combination,
false
if a new CV set is used for every parameter combination.public Classifier getBaseClassifier()
public Classifier getTrainedClassifier()
Regressor.train(jsat.regression.RegressionDataSet,
java.util.concurrent.ExecutorService)
, or null if it has not been
trained.public Regressor getBaseRegressor()
public Regressor getTrainedRegressor()
Regressor.train(jsat.regression.RegressionDataSet,
java.util.concurrent.ExecutorService)
, or null if it has not been
trained.public void setClassificationTargetScore(ClassificationScore classifierTargetScore)
classifierTargetScore
- the score to optimize via grid searchpublic ClassificationScore getClassificationTargetScore()
public void setRegressionTargetScore(RegressionScore regressionTargetScore)
regressionTargetScore
- public RegressionScore getRegressionTargetScore()
protected Parameter getParameterByName(String name) throws IllegalArgumentException
name
- the name to search forIllegalArgumentException
- if the name is not foundpublic CategoricalResults classify(DataPoint data)
Classifier
classify
in interface Classifier
data
- the data point to classifypublic boolean supportsWeightedData()
Classifier
supportsWeightedData
in interface Classifier
supportsWeightedData
in interface Regressor
public abstract ModelSearch clone()
Copyright © 2017. All rights reserved.