nip.parameters.dataset.DatasetParameters#

class nip.parameters.dataset.DatasetParameters(binarification_method: Literal['select_two', 'merge', 'random'] = 'merge', selected_classes: tuple[int, int] | None = None, binarification_seed: int | None = None, make_balanced: bool = True, max_train_size: int | None = None)[source]#

Additional parameters for the dataset.

Parameters:
  • binarification_method (BinarificationMethodType) – The method to use to turn the multi-class classification task into a binary classification task.

  • selected_classes (tuple[int, int], optional) – When selecting two classes from the original dataset, the indices of the classes to select. If not provided, the default for the dataset is used.

  • binarification_seed (int, optional) – The seed used when doing a randomised binarification. If not provided, the default for the dataset is used.

  • make_balanced (bool) – Whether to make sure the dataset is balanced.

  • max_train_size (int, optional) – The size to reduce the training set to. If not provided, the dataset is not reduced, and the full training set is used.

Methods Summary

__eq__(other)

Return self==value.

__init__([binarification_method, ...])

__post_init__()

__repr__()

Return repr(self).

_get_param_class_from_dict(param_dict)

Try to get the parameter class from a dictionary of serialised parameters.

construct_test_params()

Construct a set of basic parameters for testing.

from_dict(params_dict[, ignore_extra_keys])

Create a parameters object from a dictionary.

get(address)

Get a value from the parameters object using a dot-separated address.

to_dict()

Convert the parameters object to a dictionary.

Attributes

binarification_method

binarification_seed

make_balanced

max_train_size

selected_classes

Methods

__eq__(other)#

Return self==value.

__init__(binarification_method: Literal['select_two', 'merge', 'random'] = 'merge', selected_classes: tuple[int, int] | None = None, binarification_seed: int | None = None, make_balanced: bool = True, max_train_size: int | None = None) None#
__post_init__()[source]#
__repr__()#

Return repr(self).

classmethod _get_param_class_from_dict(param_dict: dict) type[ParameterValue] | None[source]#

Try to get the parameter class from a dictionary of serialised parameters.

Parameters:

param_dict (dict) – A dictionary of parameters, which may have come from a to_dict method. This dictionary may contain a _type key, which is used to determine the class of the parameter.

Returns:

param_class (type[ParameterValue] | None) – The class of the parameter, if it can be determined.

Raises:

ValueError – If the class specified in the dictionary is not a valid parameter class.

classmethod construct_test_params() BaseHyperParameters[source]#

Construct a set of basic parameters for testing.

classmethod from_dict(params_dict: dict, ignore_extra_keys: bool = False) BaseHyperParameters[source]#

Create a parameters object from a dictionary.

Parameters:
  • params_dict (dict) – A dictionary of the parameters.

  • ignore_extra_keys (bool, default=False) – If True, ignore keys in the dictionary that do not correspond to fields in the parameters object.

Returns:

hyper_params (BaseParameters) – The parameters object.

get(address: str) Any[source]#

Get a value from the parameters object using a dot-separated address.

Parameters:

address (str) – The path to the value in the parameters object, separated by dots.

Returns:

value (Any) – The value at the address.

Raises:

KeyError – If the address does not exist.

to_dict() dict[source]#

Convert the parameters object to a dictionary.

Turns enums into strings, and sub-parameters into dictionaries. Includes the is_random parameter if it exists.

Returns:

params_dict (dict) – A dictionary of the parameters.