Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

After we remove the alias field from ParamInfo, we can just replace Params with Map<ParamInfo<?>, Object>, which effectively contains the mapping from parameter definitions to parameter values.

6) The Param<?> class should implements the Serializable interface so that the Transformer/Estimator stages, whose instance could contain Param<?> instances, could be serialized and transferred between JobManager and TaskManagers.

Here are the usability issues with the existing APIs:

1) Params::contains() would only recognizes recognize parameters whose value has been explicitly set by Params::set(...).

...

It is possible that an algorithm will want to set and get parameters 1+ one or more times before saving the model to disk. Ideally this should not involve value serialization and deserialization overhead.

3) Param<?> class currently does not implement the Serializable interface. This would prevent classes such as Transformer/Estimator, which usually has parameter member variables, from being serializable.

Public Interfaces

1) We propose to replace WithParams/ParamInfo/ParamInfoFactory/Params with Param and WithParams as shown below. And it could be shown that the proposed interface and classes address all the issues described above.

Code Block
languagejava
/**
 * Definition of a parameter, including name, class, description, default value and the validator.
 *
 * @param <T> The type of the parameter value
 */
public class Param<T> implements Serializable {
    public final String name;
    public final Class<?> clazz;
    public final String description;
    public final ObjectT defaultValue;
    public final ParamValidatorParamValidator<T> validator;

    public Param(String name, Class<?>Class<T> clazz, String description, ObjectT defaultValue, ParamValidatorParamValidator<T> validator) {...}

    // Encodes the given object into a json-formatted string
    public String jsonEncode(Object value) throws IOException {...}

    // Decodes the json-formatted string into an object of the given type.
    public T jsonDecode(String json) throws IOException {...}
}


...