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

Class RandomSearch

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


    public class RandomSearch
    extends ModelSearch
    Random Search is a simple method for tuning the parameters of a classification or regression algorithm. Each parameter is given a distribution that represents the values of interest, and trials are done by randomly sampling each parameter from their respective distributions. Compared to GridSearch this method does better when lots of values are to be tested or when 2 or more parameters are to be evaluated.
    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 : Bergstra, J., & Bengio, Y. (2012). Random Search for Hyper-Parameter Optimization. Journal ofMachine Learning Research, 13, 281–305.
    See Also:
    Serialized Form
    • Constructor Detail

      • RandomSearch

        public RandomSearch(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
      • RandomSearch

        public RandomSearch(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
      • RandomSearch

        public RandomSearch(RandomSearch 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.

        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
      • setTrials

        public void setTrials(int trials)
        Sets the number of trials or samples that will be taken. This value is the number of models that will be trained and evaluated for their performance
        Parameters:
        trials - the number of models to build and evaluate
      • getTrials

        public int getTrials()
        Returns:
        the number of models that will be built to evaluate
      • addParameter

        public void addParameter(DoubleParameter param,
                                 Distribution dist)
        Adds a new double parameter to be altered for the model being tuned.
        Parameters:
        param - the model parameter
        initialSearchValues - the distribution to sample from for this parameter
      • addParameter

        public void addParameter(IntParameter param,
                                 Distribution dist)
        Adds a new double parameter to be altered for the model being tuned.
        Parameters:
        param - the model parameter
        initialSearchValues - the distribution to sample from for this parameter
      • addParameter

        public void addParameter(java.lang.String name,
                                 Distribution dist)
        Adds a new 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.