public class GridSearch extends ModelSearch
Parameterized
interface. By
default, no parameters are selected for optimizations. This is because
parameters value ranges are often algorithm specific. As such, the user must
specify the parameters and the values to test using the addParameter
methods.addParameter(jsat.parameters.DoubleParameter, double[])
,
addParameter(jsat.parameters.IntParameter, int[])
,
Serialized FormbaseClassifier, baseRegressor, classificationTargetScore, folds, regressionTargetScore, reuseSameCVFolds, searchParams, trainedClassifier, trainedRegressor, trainFinalModel, trainModelsInParallel
Constructor and Description |
---|
GridSearch(Classifier baseClassifier,
int folds)
Creates a new GridSearch to tune the specified parameters of a
classification model.
|
GridSearch(GridSearch toCopy)
Copy constructor
|
GridSearch(Regressor baseRegressor,
int folds)
Creates a new GridSearch to tune the specified parameters of a regression
model.
|
Modifier and Type | Method and Description |
---|---|
void |
addParameter(DoubleParameter param,
double... initialSearchValues)
Adds a new double parameter to be altered for the model being tuned.
|
void |
addParameter(IntParameter param,
int... initialSearchValues)
Adds a new int parameter to be altered for the model being tuned.
|
void |
addParameter(String name,
double... initialSearchValues)
Adds a new double parameter to be altered for the model being tuned.
|
void |
addParameter(String name,
int... initialSearchValues)
Adds a new integer parameter to be altered for the model being tuned.
|
int |
autoAddParameters(DataSet data)
This method will automatically populate the search space with parameters
based on which Parameter objects return non-null distributions.
|
int |
autoAddParameters(DataSet data,
int paramsEach)
This method will automatically populate the search space with parameters
based on which Parameter objects return non-null distributions.
Note, using this method with Cross Validation has the potential for over-estimating the accuracy of results if the data set is actually used to for parameter guessing. |
GridSearch |
clone() |
boolean |
isUseWarmStarts() |
void |
setUseWarmStarts(boolean useWarmStarts)
Sets whether or not warm starts are used, but only if the model in use
supports warm starts.
|
void |
train(RegressionDataSet dataSet) |
void |
train(RegressionDataSet dataSet,
ExecutorService threadPool) |
void |
trainC(ClassificationDataSet dataSet)
Trains the classifier and constructs a model for classification using the
given data set.
|
void |
trainC(ClassificationDataSet dataSet,
ExecutorService threadPool)
Trains the classifier and constructs a model for classification using the
given data set.
|
classify, getBaseClassifier, getBaseRegressor, getClassificationTargetScore, getParameterByName, getRegressionTargetScore, getTrainedClassifier, getTrainedRegressor, isReuseSameCVFolds, isTrainFinalModel, isTrainModelsInParallel, regress, setClassificationTargetScore, setRegressionTargetScore, setReuseSameCVFolds, setTrainFinalModel, setTrainModelsInParallel, supportsWeightedData
public GridSearch(Regressor baseRegressor, int folds)
addParameter(jsat.parameters.DoubleParameter, double[])
baseRegressor
- the regressor to tune the parameters offolds
- the number of folds of cross-validation to perform to
evaluate each combination of parametersFailedToFitException
- if the base regressor does not implement
Parameterized
public GridSearch(Classifier baseClassifier, int folds)
addParameter(jsat.parameters.DoubleParameter, double[])
baseClassifier
- the classifier to tune the parameters offolds
- the number of folds of cross-validation to perform to
evaluate each combination of parametersFailedToFitException
- if the base classifier does not implement
Parameterized
public GridSearch(GridSearch toCopy)
toCopy
- the object to copypublic int autoAddParameters(DataSet data)
data
- the data set to get parameter estimates frompublic int autoAddParameters(DataSet data, int paramsEach)
data
- the data set to get parameter estimates fromparamsEach
- the number of parameters value to try for each parameter foundpublic void setUseWarmStarts(boolean useWarmStarts)
true
by default.useWarmStarts
- true
if warm starts should be used when
possible, false
otherwise.public boolean isUseWarmStarts()
true
if warm starts will be used when possible.
false
if they will not.public void addParameter(DoubleParameter param, double... initialSearchValues)
param
- the model parameterinitialSearchValues
- the values to try for the specified parameterpublic void addParameter(String name, double... initialSearchValues)
name
- the name of the parameterinitialSearchValues
- the values to try for the specified parameterpublic void addParameter(IntParameter param, int... initialSearchValues)
param
- the model parameterinitialSearchValues
- the values to try for the specified parameterpublic void addParameter(String name, int... initialSearchValues)
name
- the name of the parameterinitialSearchValues
- the values to try for the specified parameterpublic void train(RegressionDataSet dataSet, ExecutorService threadPool)
public void train(RegressionDataSet dataSet)
public void trainC(ClassificationDataSet dataSet, ExecutorService threadPool)
Classifier
dataSet
- the data set to train onthreadPool
- the source of threads to use.public void trainC(ClassificationDataSet dataSet)
Classifier
dataSet
- the data set to train onpublic GridSearch clone()
clone
in interface Classifier
clone
in interface Regressor
clone
in class ModelSearch
Copyright © 2017. All rights reserved.