Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RandomSearch #30

Merged
merged 39 commits into from
Apr 3, 2020
Merged

Implement RandomSearch #30

merged 39 commits into from
Apr 3, 2020

Conversation

ablaom
Copy link
Member

@ablaom ablaom commented Apr 1, 2020

This is more-or-less the implementation proposed at JuliaAI/MLJ.jl#37, with addition that tuples of the form (hyperparameter_name, sampler) can be specified in the range vector, where sampler is just something implementing rng.

Here's the updated doc-string:


RandomSearch(bounded=Distributions.Uniform,
             positive_unbounded=Distributions.Gamma,
             other=Distributions.Normal,
             rng=Random.GLOBAL_RNG)

Instantiate a random search tuning strategy, for searching over
Cartesian hyperparameter domains, with customizable priors in each
dimenension.

Supported ranges:

  • a single one-dimensional range (ParamRange object) r

  • a pair of the form (r, d), with r as above and where d is a
    probability vector of the same length as r.values, if r is a
    NominalRange, and is otherwise: (i) any
    Distributions.UnivariateDistribution instance; or (ii) one of
    the subtypes of Distributions.UnivariateDistribution listed in
    the table below, for automatic fitting using Distributions.fit(d, r) (a distribution whose support always lies between r.lower and
    r.upper.)

  • any pair of the form (field, s), where field is the (possibly
    nested) name of a field of the model to be tuned, and s an
    arbitrary sampler object for that field. This means only that
    rand(rng, s) is defined and returns valid values for the field.

  • any vector of objects of the above form

distribution types for fitting to ranges of this type
Arcsine, Uniform, Biweight, Cosine, Epanechnikov, SymTriangularDist, Triweight bounded
Gamma, InverseGaussian, Poisson positive (bounded or unbounded)
Normal, Logistic, LogNormal, Cauchy, Gumbel, Laplace any

ParamRange objects are constructed using the range method.

Examples:

range1 = range(model, :hyper1, lower=1, origin=2, unit=1)

range2 = [(range(model, :hyper1, lower=1, upper=10), Arcsine),
           range(model, :hyper2, lower=2, upper=4),
          (range(model, :hyper2, lower=2, upper=4), Normal(0, 3)),
           range(model, :hyper3, values=[:ball, :tree], [0.3, 0.7])]

# uniform sampling of :(atom.λ) from [0, 1] without defining a NumericRange:
struct MySampler end
Base.rand(rng::AbstractRNG, ::MySampler) = rand(rng)
range3 = (:(atom.λ), MySampler(), range1)

Algorithm

Models for evaulation are generated by sampling each range r using
rand(rng, s) where, s = sampler(r, d). See sampler for details. If d
is not specified, then sampling is uniform (with replacement) in the
case of a NominalRange, and is otherwise given by the defaults
specified by the tuning strategy parameters bounded,
positive_unbounded, and other, depending on the NumericRange
type.

See also TunedModel, range, sampler.

@ablaom ablaom requested a review from tlienart April 1, 2020 04:39
@ablaom
Copy link
Member Author

ablaom commented Apr 1, 2020

@tlienart A superficial look over would be great, only if you have time.

Copy link
Collaborator

@tlienart tlienart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it all seems quite sensible to me 👍 I wonder about making this explicit difference between rightunbounded and positiveunbounded shifted by a bit but I'm sure you've already considered all this.

I'm glad to see this anyway 😄

README.md Outdated Show resolved Hide resolved
src/range_methods.jl Show resolved Hide resolved
src/strategies/random_search.jl Outdated Show resolved Hide resolved
@ablaom
Copy link
Member Author

ablaom commented Apr 3, 2020

Many thanks @tlienart .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants