Skip to main content

RandomUnderSamplerConverter

Converter
DashAI.back.converters.imbalanced_learn.RandomUnderSamplerConverter

Balance class distribution by randomly discarding majority-class samples.

Under-sampling addresses class imbalance by reducing the size of one or more over-represented classes rather than synthesising new minority-class examples. RandomUnderSampler achieves this by drawing a random subset of the majority class without replacement until the desired sampling_strategy ratio is reached.

The sampling_strategy parameter controls the resulting ratio between the minority and majority class after resampling. When set to "auto", the majority class is down-sampled until it matches the size of the next largest class. A float value specifies the desired minority-to-majority ratio directly.

Input column types are preserved in the output. Type determination is delegated to the transform method of the parent wrapper.

Wraps imblearn.under_sampling.RandomUnderSampler.

References​

Parameters​

sampling_strategy, default=auto
Sampling strategy (float or 'auto') to reduce majority class.
random_state, default=None
Seed for reproducibility.

Methods​

fit(self, x: 'DashAIDataset', y: 'DashAIDataset') -> Type[DashAI.back.converters.base_converter.BaseConverter]

Defined on ImbalancedLearnWrapper

Resample the dataset by calling fit_resample and store the result.

Parameters

x : DashAIDataset
The input feature dataset.
y : DashAIDataset
The target label dataset (required; must be non-empty).

Returns

Type[BaseConverter]
The fitted sampler instance (self).

get_credential(self, name: str)

Defined on ConfigObject

Resolve a registered credential component by name.

Parameters

name : str
Credential component class name (e.g. "HuggingFaceCredential").

Returns

BaseCredential
An instance of the requested credential component.

get_metadata(cls) -> 'Dict[str, Any]'

Defined on BaseConverter

Get metadata for the converter, used by the DashAI frontend.

Parameters

cls : type
The converter class (injected automatically by Python for classmethods).

Returns

Dict[str, Any]
Dictionary containing display name, short description, image preview path, category, icon, color, and whether the converter is supervised.

get_output_type(self, column_name: str = None) -> DashAI.back.types.dashai_data_type.DashAIDataType

Defined on ImbalancedLearnWrapper

Return a resampled column's type: its input type, recorded in fit.

Parameters

column_name : str or None, optional
The column to look up. Defaults to None.

Returns

DashAIDataType or None
The column's input type, or None before fit or for an unknown column.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

infer_output_columns(self, inputs: 'List[StateItem]') -> 'StructureDelta'

Defined on BaseConverter

Estimate what this converter does to its scope, without any data.

Parameters

inputs : list of ColumnItem | BlockItem
The dataset state items in this converter's scope.

Returns

StructureDelta
The scope items that survive (maybe retyped) and the new items.

rows_to_keep(self, x: "'DashAIDataset'") -> 'List[int]'

Defined on BaseConverter

Positions of the rows of x that survive this converter.

Parameters

x : DashAIDataset
The converter's scope columns of one split.

Returns

list of int
0-based positions of the kept rows, in order.

transform(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'DashAIDataset'

Defined on ImbalancedLearnWrapper

Return the resampled dataset stored during fit.

Parameters

x : DashAIDataset
The original feature dataset (used only for type information).
y : DashAIDataset, optional
The original target dataset (used only for type information). Defaults to None.

Returns

DashAIDataset
The combined resampled dataset (features + target) produced by fit.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.

Parameters

raw_data : dict
A dictionary with the data provided by the user to initialize the model.

Returns

dict
A validated dictionary with the necessary objects.