scicloj.metamorph.ml.gridsearch

Gridsearching as defined by create a map with gridsearch definitions for its values and then gridsearching which produces a sequence of full defined maps.

The initial default implementation uses the sobol sequence.

Categories

    Other vars: categorical linear sobol-gridsearch

    categorical

    (categorical value-vec)

    Creates a categorical grid search definition from a vector of values.

    value-vec - Vector of categorical values to search over

    Returns a grid search definition map that will enumerate all values in the vector during grid search. This is a convenience wrapper around linear for categorical parameters.

    Example: (categorical [:adam :sgd :rmsprop]) creates a definition that will try all three optimizers.

    See also: linear, sobol-gridsearch

    linear

    (linear start end n-steps res-dtype-or-space)(linear start end n-steps)(linear start end)

    Creates a linear grid search definition for hyperparameter tuning.

    • start - Starting value of the range
    • end - Ending value of the range
    • n-steps - Number of evenly-spaced steps (default: 100)
    • res-dtype-or-space - Either a datatype keyword (:float64, :int32, etc.) or a vector of categorical values (default: :float64)

    Returns a grid search definition map that can be used with sobol-gridsearch.

    When res-dtype-or-space is a vector, values are mapped to categorical options by index. For example, [:small :medium :large] with 3 steps generates those three categorical values.

    See also: categorical, sobol-gridsearch

    sobol-gridsearch

    (sobol-gridsearch opt-map start-idx)(sobol-gridsearch opt-map)

    Given an map of key->values where some of the values are gridsearch definitions produce a sequence of fully defined maps.

    user> (require '[tech.v3.ml.gridsearch :as ml-gs])
    nil
    user> (def opt-map  {:a (ml-gs/categorical [:a :b :c])
                         :b (ml-gs/linear 0.01 1 10)
                         :c :not-searched})
    user> opt-map
    {:a
     {:tech.v3.ml.gridsearch/type :linear,
      :start 0.0,
      :end 2.0,
      :n-steps 3,
      :result-space [:a :b :c]}
      ...
    
    user> (ml-gs/sobol-gridsearch opt-map)
    ({:a :b, :b 0.56, :c :not-searched}
     {:a :c, :b 0.22999999999999998, :c :not-searched}
     {:a :b, :b 0.78, :c :not-searched}
    ...