Documentation of 'jsat.parameters.GridSearch' Java class
GridSearch
jsat.parameters

Class GridSearch

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Classifier, Regressor


    public class GridSearch
    extends ModelSearch
    GridSearch is a simple method for tuning the parameters of a classification or regression algorithm. It naively tries all possible pairs of parameter values given. For this reason, it works best when only a small number of parameters need to be turned.
    The model it takes must implement the 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.
    See Also:
    addParameter(jsat.parameters.DoubleParameter, double[]), addParameter(jsat.parameters.IntParameter, int[]), Serialized Form
    • Constructor Detail

      • GridSearch

        public GridSearch(Regressor baseRegressor,
                          int folds)
        Creates a new GridSearch to tune the specified parameters of a regression model. The parameters still need to be specified by calling addParameter(jsat.parameters.DoubleParameter, double[])
        Parameters:
        baseRegressor - the regressor to tune the parameters of
        folds - the number of folds of cross-validation to perform to evaluate each combination of parameters
        Throws:
        FailedToFitException - if the base regressor does not implement Parameterized
      • GridSearch

        public GridSearch(Classifier baseClassifier,
                          int folds)
        Creates a new GridSearch to tune the specified parameters of a classification model. The parameters still need to be specified by calling addParameter(jsat.parameters.DoubleParameter, double[])
        Parameters:
        baseClassifier - the classifier to tune the parameters of
        folds - the number of folds of cross-validation to perform to evaluate each combination of parameters
        Throws:
        FailedToFitException - if the base classifier does not implement Parameterized
      • GridSearch

        public GridSearch(GridSearch toCopy)
        Copy constructor
        Parameters:
        toCopy - the object to copy
    • Method Detail

      • autoAddParameters

        public int autoAddParameters(DataSet data)
        This method will automatically populate the search space with parameters based on which Parameter objects return non-null distributions. Each parameter will be tested with 10 different values

        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.

        It is possible for this method to return 0, indicating that no default parameters could be found. The intended interpretation is that there are no parameters that you need to tune to get good performance from the given model. Though there will be cases where the author has simply missed a class.
        Parameters:
        data - the data set to get parameter estimates from
        Returns:
        the number of parameters added
      • autoAddParameters

        public 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.
        Parameters:
        data - the data set to get parameter estimates from
        paramsEach - the number of parameters value to try for each parameter found
        Returns:
        the number of parameters added
      • setUseWarmStarts

        public void setUseWarmStarts(boolean useWarmStarts)
        Sets whether or not warm starts are used, but only if the model in use supports warm starts. This is set to true by default.
        Parameters:
        useWarmStarts - true if warm starts should be used when possible, false otherwise.
      • isUseWarmStarts

        public boolean isUseWarmStarts()
        Returns:
        true if warm starts will be used when possible. false if they will not.
      • addParameter

        public void addParameter(DoubleParameter param,
                                 double... initialSearchValues)
        Adds a new double parameter to be altered for the model being tuned.
        Parameters:
        param - the model parameter
        initialSearchValues - the values to try for the specified parameter
      • addParameter

        public void addParameter(java.lang.String name,
                                 double... initialSearchValues)
        Adds a new double parameter to be altered for the model being tuned.
        Parameters:
        name - the name of the parameter
        initialSearchValues - the values to try for the specified parameter
      • addParameter

        public void addParameter(IntParameter param,
                                 int... initialSearchValues)
        Adds a new int parameter to be altered for the model being tuned.
        Parameters:
        param - the model parameter
        initialSearchValues - the values to try for the specified parameter
      • addParameter

        public void addParameter(java.lang.String name,
                                 int... initialSearchValues)
        Adds a new integer parameter to be altered for the model being tuned.
        Parameters:
        name - the name of the parameter
        initialSearchValues - the values to try for the specified parameter
      • train

        public void train(ClassificationDataSet dataSet,
                          boolean parallel)
        Description copied from interface: Classifier
        Trains the classifier and constructs a model for classification using the given data set. If the training method knows how, it will used the threadPool to conduct training in parallel. This method will block until the training has completed.
        Parameters:
        dataSet - the data set to train on
        parallel - true if multiple threads should be used to train the model. false if it should be done in a single threaded manner.

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.