CausalDiscoverySelector<T>

Models & Types ยท AiDotNet.CausalDiscovery

Feature selector that uses any causal discovery algorithm to select features based on causal relationships.

Inheritance: TransformerBase<T, Matrix<T>, Matrix<T>> โ†’ CausalDiscoverySelector<T>

For Beginners

Instead of selecting features by correlation or mutual information, this selector uses causal discovery to find features that actually CAUSE the target variable (or are caused by it). This often leads to better, more robust models because causal features remain predictive even when the data distribution changes.

How It Works

This wrapper allows any ICausalDiscoveryAlgorithm to be used as a feature selector within the preprocessing pipeline. It discovers the causal graph, then selects the top features that have the strongest causal connections to the target variable.

Usage:

Constructors

Constructor Summary
CausalDiscoverySelector(CausalDiscoveryAlgorithmType algorithmType, int maxFeatures, double edgeThreshold, CausalDiscoveryOptions options, int[] columnIndices) Creates a new CausalDiscoverySelector using the specified algorithm type.
CausalDiscoverySelector(ICausalDiscoveryAlgorithm<T> algorithm, int maxFeatures, double edgeThreshold, int[] columnIndices) Creates a new CausalDiscoverySelector using a pre-created algorithm instance.

Properties

Property Summary
CausalGraph<T> CausalGraph { get; } Gets the discovered causal graph from the most recent Fit() call.
bool SupportsInverseTransform { get; }
double[] ConnectionStrengths { get; } Gets the connection strengths of each feature to the target.
int[] SelectedIndices { get; } Gets the selected feature indices.

Methods

Method Summary
Matrix<T> FitTransform(Matrix<T> data, Vector<T> target) Fits the selector and transforms the data in one step.
bool[] GetSupportMask() Gets a boolean mask indicating which input features are selected.
string[] GetFeatureNamesOut(string[] inputFeatureNames)
void Fit(Matrix<T> data, Vector<T> target) Fits the selector by discovering the causal graph and selecting features connected to the target.