Selectable Types
The select
and multi_select
methods enable categorical parameter configuration. These methods support both single and multiple value selection with flexible validation options.
I'll help improve the documentation for the select and multi_select parameters by adding the requested information. Here's the enhanced version:
Select & Multi_select Parameters
The select
and multi_select
methods enable categorical parameter configuration using either lists or dictionaries. These methods support both single and multiple value selection with flexible validation options.
Function Signatures
select
multi_select
Parameters
options
: Either a list of valid values or a dictionary mapping keys to valuesdefault
: Default value(s) if none provided (single value for select, list for multi_select)options_only
: When True, only allows values from the predefined options
Pre-defined Parameter Forms
List Form
Use when the parameter keys and values are identical:
Dictionary Form
Use when parameter keys need to map to different values:
Value Resolution
When using dictionary form, the configuration system maps input keys to their corresponding values:
When to Use Dictionary Form?
Dictionary form is recommended when working with:
Long string values:
{"haiku": "claude-3-haiku-20240307"}
Precise numeric values:
{"small": 1.524322}
Object references:
{"rf": RandomForest(n_estimators=100)}
Default Values
The default
parameter must be a valid option from the predefined choices. For dictionary form, the default must be one of the keys (not values).
List Form Defaults
When using list form, the default must be one of the items in the list:
Dictionary Form Defaults
When using dictionary form, the default must be one of the dictionary keys:
Instantiating With Missing Default Values
If no default is provided, a value must be specified during configuration:
Value Validation
The options_only
parameter determines how strictly values are validated:
Valid Instantiation Examples
Invalid Instantiation Examples
I'll improve the Reproducibility and Value History section by adding clear examples:
Reproducibility and Value History
Hypster maintains a historical record of parameter values to ensure configuration reproducibility across different runs. This history can be accessed using my_config.get_last_snapshot()
, allowing you to view and reuse previous configurations.
Value Serialization
When instantiating parameters with values outside the predefined options, Hypster handles serialization in two ways:
Simple types (str, int, float, bool)
are properly logged and reproducible, regardless of if they were originally in the pre-defined options or not.
Complex objects
Complex object (classes, functions, anything outside of str, int, float, bool) will be serialized as strings using str(value)
and will not be reproducible for future runs.
Examples
Last updated