API Reference / features /

selection/

Feature selection methods for tuiml.

This module provides a wide range of feature selection algorithms that follow the scikit-learn fit/transform pattern. These filters and wrappers help in reducing overfitting, improving accuracy, and reducing training time by identifying the most relevant features.

Overview

The selectors are categorized into several strategies:

Univariate Selectors ~~~~~~~~~~~~~~~~~~~~ These score each feature independently using statistical tests:
  • SelectKBestSelector: Keep top k features.
  • SelectPercentileSelector: Keep top percentage.
  • SelectThresholdSelector: Keep by raw score.
  • SelectFprSelector: Keep by signicance (p-value).
Subset Selection (Filter & Wrapper) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ These evaluate groups of features together:
  • CFSSelector: Correlation-based Subset Selection.
  • SequentialFeatureSelector: Greedy forward/backward.
  • BestFirstSelector: Search with backtracking.
  • WrapperSelector: Evaluates subsets with an estimator.
Unsupervised & Stochastic ~~~~~~~~~~~~~~~~~~~~~~~~~
  • VarianceThresholdSelector: Removes constant features.
  • RandomSubsetSelector: Stochastic subsampling.
  • BootstrapFeaturesSelector: Sample with replacement.

Univariate selection with Information Gain:

python
>>> from tuiml.features.selection import SelectKBestSelector
>>> from tuiml.evaluation.metrics import information_gain
>>> import numpy as np
>>> X, y = np.random.randn(20, 10), np.random.randint(0, 2, 20)
>>> selector = SelectKBestSelector(score_func=information_gain, k=5)
>>> X_new = selector.fit_transform(X, y)

Automatic subset selection using CFS:

python
>>> from tuiml.features.selection import CFSSelector
>>> cfs = CFSSelector()
>>> X_new = cfs.fit_transform(X, y)
>>> print(f"Selected: {cfs.get_support(indices=True)}")

Modules