BPt.ValueSubset#

class BPt.ValueSubset(name, values, decode_values=False)[source]#

ValueSubset is special wrapper class for BPt designed to work with Subjects style input. It is used to select a subset of subjects based on a loaded column’s value.

Parameters
namestr

The name of the loaded column in Dataset in which the values refer to.

In the case of selecting values from an overlap of multiple columns, you can first create a new overlap column. See method Dataset.add_unique_overlap(), then pass the name of the overlap column here.

valuesstr, float or list of

This parameter refers to either a single or list of values in which if the loaded subject has the value, or one of the values, in the column selected via name, then that subject will be selected.

decode_valuesbool, optional

This parameter is boolean flag which represents if encoded values should be used or not. What this asks is that should the actual ordinal post encoded value be specified, or the should the value be set based on the original encoded name.

This parameter is only relevant assuming the underlying name column was encoding using an encoding method from Dataset, for example Dataset.to_binary() or Dataset.ordinalize().

default = False

Examples

This wrapper can be used as follows, just specify an object as

ValueSubset(name, values)

Where name is the name of a loaded non input categorical column / feature, and value is the subset of values from that column to select subjects by. E.g., if you wanted to select just subjects of a specific sex, and assuming the variable was properly loaded,

subjects = ValueSubset('sex', 0)

Which would specify only subjects with ‘sex’ equal to 0. You may also optionally pass more than one value to values, E.g.,

subjects = ValuesSubset(name='site', values=[0, 1, 5])

Would select the subset of subjects from sites 0, 1 and 5.

We can also consider using the decode_values parameter. For example, let’s say sex originally had values ‘M’ and ‘F’ and then Dataset.binarize() was used to transform the values internally to 0 and 1. If decode_values is set as the default value of False, then you must pass value = 0 or 1, but if decode_values = True, then it allows passing value = ‘M’ or ‘F’. E.g.,

subjects = ValueSubset('sex', 'M', decode_values=True)