GeneticAlgorithmFS<T>

Models & Types · AiDotNet.Preprocessing.FeatureSelection.Wrapper

Genetic Algorithm for feature selection.

Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> → GeneticAlgorithmFS<T>

Implements: IFixedCountFeatureSelector<T>, ISupervisedFeatureSelector<T>

For Beginners

Think of it as natural selection for features. Each individual is a binary string (1=include feature, 0=exclude). The fittest individuals (best feature subsets) “breed” to create new solutions. Over generations, the population evolves toward better feature combinations.

How It Works

Genetic Algorithms (GA) evolve a population of candidate feature subsets using biological-inspired operators: selection, crossover, and mutation. Better solutions are more likely to survive and produce offspring, gradually improving the population.

Constructors

Constructor Summary
GeneticAlgorithmFS(int nFeaturesToSelect, int populationSize, int nGenerations, double crossoverRate, double mutationRate, int eliteSize, Func<Matrix<T>, Vector<T>, int[], T> scorer, int? randomState, int[] columnIndices)

Properties

Property Summary
Vector<T> FeatureScores { get; }
bool SupportsInverseTransform { get; }
double CrossoverRate { get; }
double MutationRate { get; }
int NFeaturesToSelect { get; }
int[] SelectedIndices { get; }

Methods

Method Summary
Matrix<T> FitTransform(Matrix<T> data, Vector<T> target)
bool[] GetSupportMask()
string[] GetFeatureNamesOut(string[] inputFeatureNames)
void Fit(Matrix<T> data, Vector<T> target)