GANDALFBase<T>

Base Classes · AiDotNet.NeuralNetworks.Tabular

Base implementation of GANDALF (Gated Additive Neural Decision Forest).

Implements: IParameterSource<T>

Known derived types: GANDALFClassifier<T>, GANDALFRegression<T>

For Beginners

GANDALF works like a smart forest of decision trees:

Architecture:

  1. Gating Network: Learns which features are important
  2. Neural Decision Trees: Trees with learnable split decisions
  3. Soft Routing: Samples can go down multiple paths with probabilities
  4. Additive Ensemble: Tree outputs are summed for final prediction

Key insight: Traditional trees have hard decisions (left or right). GANDALF uses soft decisions where a sample partially goes both ways, making the whole thing differentiable and trainable with gradient descent.

Example flow: Input → Gating (feature importance) → Trees (soft routing) → Sum → Output

How It Works

GANDALF combines gated feature selection with an ensemble of differentiable decision trees. Each tree makes soft routing decisions, and their outputs are combined additively.

Properties

Property Summary
int NumTrees { get; } Gets the number of trees.
int TreeDepth { get; } Gets the tree depth.
long ParameterCount { get; }

Methods

Method Summary
Tensor<T> GetGatingWeights() Gets the gating weights (feature importance) from the last forward pass.
Vector<T> GetFeatureImportance(Tensor<T> features) Gets the average feature importance across all predictions.
Vector<T> GetParameters() Reads every parameter in traversal order.
void ResetState() Resets internal state.
void SetParameters(Vector<T> parameters) Restores every parameter, in the order GetParameters emitted them.
void UpdateParameters(T learningRate) Updates all parameters using the calculated gradients.