skrub.DataOp.skb.get_choices#
- DataOp.skb.get_choices(named_only=False)[source]#
Get all the choices used in the DataOp.
- Parameters:
- named_only
bool, default =False If True, only choices that have their
nameattribute set are returned. Those are the only names for which a value can be passed in the environment passed toeval().If False, all choices are returned. For choices that have a
name, thatnameis their key in the returned dictionary. For other choices, the key is arbitrary but stable for a same DataOp and its clones, and is the same string that is used in the parallel coordinate plots produced byParamSearch.plot_results().
- named_only
- Returns:
dictKeys are names, and values the corresponding choice object.
See also
DataOp.skb.get_varsSimilar function for getting variables created with
var()and DataOps whose name was set with.skb.set_name.DataOp.skb.describe_defaultsGet a dictionary showing the default values for choices. Only choices that actually get used in the default configuration are shown.
SkrubLearner.get_named_paramsGet a dictionary mapping choice name to value in a SkrubLearner.
SkrubLearner.set_named_paramsSet choice values by name on a SkrubLearner.
Examples
>>> import skrub >>> dop = ( ... skrub.var("a") ... + skrub.choose_int(0, 10, name="b") ... + skrub.choose_float(0.0, 1.0) ... ) >>> dop.skb.get_choices() {'b': choose_int(0, 10, name='b'), 'choose_float(0.0, 1.0)': choose_float(0.0, 1.0)}
With
named_onlywe can restrict to choices that have an actual name (only choices with a name can be passed in an environment, and toSkrubLearner.set_named_params()):>>> dop.skb.get_choices(named_only=True) {'b': choose_int(0, 10, name='b')}
Similarly, vars can be obtained:
>>> dop.skb.get_vars() {'a': <Var 'a'>}
All the names that can be passed in the environment are thus obtained with:
>>> list(dop.skb.get_vars(all_named_ops=True) | dop.skb.get_choices(named_only=True)) ['a', 'b']