BalanceClasses¶
Balance the per-class trial counts in the data.
A class here refers to a numerical group of trials/instances in some data (e.g., class 0 may be one set of experimental conditions, and class 1 may be another). The node ensures that the data contain equal proportions of trials across these classes, which is sometimes necessary to ensure that downstream statistics and/or machine learning are sound (e.g., not unfairly biased towards an over-represented class, or accurately quantifying things like the error rate of ML models when all classes are being equally likely to occur in the data). This node should be called after AssignTargets (or an equivalent node that associates instances with numeric classes), and can be used on either continuous or segmented data. Note that, if you use this node on continuous data, this node will drop all event markers that are not of one of the designated target classes (as set via e.g., AssignTargets). Typically that is all markers where the TargetValue is set to the special value nan. Version 1.2.0
Ports/Properties¶
data¶
Data to process.
strategy¶
Strategy to apply. Duplicate will only duplicate under-represented trials, and drop will only drop excess over-represented trials. Mixed sets the target number of trials to the mean of the class trial counts, and duplicates or drops trials for each class accordingly to reach it. With target, under-represented trials will be duplicated and over-represented trials will be dropped to meet the target trial count specified in the target_count property. Bypass causes the node to do nothing.
max_factor¶
Maximum factor by which to duplicate trials if the duplicate strategy is selected, or by which to reduce trials if the drop strategy is selected, after which the other class(es) or dropped or duplicated, respectively, until the classes are balanced. Ignored if None or 0 or the mixed strategy is used.
target_count¶
Target number of trials per class. This only applies if the strategy is set to target. In this case, all classes will be duplicated or dropped as needed in order to reach the target count per class. Ignored if None or 0.
field_name¶
Name of field containing the classes to rebalance. In the output, values of this field will occur approximately equally in the given instances. Only change this from TargetValue if the named field has been added to the Instance axis upstream.
binning_field¶
Optional name of field to bin on. This will, for each unique value in this field, perform the balancing within all instances where the field takes on the same value.
randseed¶
Optionally the random seed to use to get deterministic results.
verbose¶
Print info and warning messages. 0: no output; 1: print results only; 2: print errors/warnings; 3: print all.
set_breakpoint¶
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.
metadata¶
User-definable meta-data associated with the node. Usually reserved for technical purposes.