Skip to main content

VarianceThreshold

Converter
DashAI.back.converters.scikit_learn.VarianceThreshold

Remove features whose variance across the training set is below a threshold.

For each feature column the sample variance is computed during fitting::

Var(x) = E[x^2] - (E[x])^2

Feature columns for which Var(x) < threshold are removed. Because the criterion is purely based on the marginal variance of each feature, this selector requires no class labels and runs in O(n * p) time.

Common use cases include:

  • Constant-feature removal: with the default threshold=0.0 any feature that takes the same value in every training sample is dropped.
  • Near-constant-feature removal: for binary features, a threshold of p * (1 - p) drops features that are True in fewer than a fraction p of samples (e.g. threshold=0.8 * 0.2 = 0.16 removes features that are True in less than 20 % of samples).
  • Pre-filtering before expensive selectors: quickly reducing dimensionality before applying supervised selection methods such as SelectKBest or RFECV.

References​

Parameters​

threshold : number, default=0.0
Features with a variance lower than this threshold will be removed.

Methods​

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

Defined on VarianceThreshold

Fit the selector, remembering input types and tolerating empty output.

Parameters

x : DashAIDataset
The input dataset to fit the selector on.
y : DashAIDataset, optional
Ignored; present for API consistency.

Returns

VarianceThreshold
The fitted selector instance (self).

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

Defined on VarianceThreshold

Return the original DashAI data type of a retained column.

Parameters

column_name : str, optional
The name of the retained column. Defaults to None.

Returns

DashAIDataType
The original type of the column. Falls back to float64 when the input type is unknown (the selector only operates on numbers).

build_report(self, data: 'Dict[str, Any]') -> 'Dict[str, Any]'

Defined on BaseConverter

Wrap converter-specific data with the producer converter name.

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_report(self) -> 'Union[Dict[str, Any], None]'

Defined on BaseConverter

Return the converter report produced after execution, if any.

Returns

Dict[str, Any] or None
JSON-serializable report dict, or None when the converter does not produce one.

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 SklearnWrapper

Transform the data using the fitted scikit-learn transformer.

Parameters

x : DashAIDataset
The input dataset to transform.
y : DashAIDataset, optional
Not used. Present for API consistency. Defaults to None.

Returns

DashAIDataset
The transformed dataset with updated DashAI column types.

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.