TabRRegression<T>

Models & Types · AiDotNet.NeuralNetworks.Tabular

TabR implementation for regression tasks.

Inheritance: TabRBase<T> → TabRRegression<T>

For Beginners

TabR for regression is like estimating a home’s price by looking at similar homes that have sold recently.

Prediction process:

  1. Encode the input features
  2. Find similar training samples (neighbors)
  3. Aggregate neighbor information using attention
  4. Combine with encoded input to predict values

Benefits:

  • Naturally handles local patterns (similar inputs → similar outputs)
  • Can explain predictions by showing influential neighbors
  • Works well with non-linear relationships

Example:

How It Works

TabRRegression uses retrieval-augmented predictions for regression. It finds similar training samples and uses their information to help predict continuous values.

Constructors

Constructor Summary
TabRRegression(int numFeatures, int outputDimension, TabROptions<T> options) Initializes a new instance of the TabRRegression class.

Properties

Property Summary
int OutputDimension { get; } Gets the output dimension.

Methods

Method Summary
List<List<ValueTuple<int, T>>> GetPredictionExplanations(Tensor<T> features) Gets interpretability information: which neighbors influenced each prediction.
T ComputeMAELoss(Tensor<T> predictions, Tensor<T> targets) Computes the Mean Absolute Error loss.
T ComputeMSELoss(Tensor<T> predictions, Tensor<T> targets) Computes the Mean Squared Error loss.
T ComputeR2Score(Tensor<T> features, Tensor<T> targets) Computes the R² score (coefficient of determination).
T ComputeRMSE(Tensor<T> features, Tensor<T> targets) Computes the Root Mean Squared Error.
T TrainStep(Tensor<T> features, Tensor<T> targets, T learningRate, Vector<int> sampleIndices) Performs a single training step.
Tensor<T> Forward(Tensor<T> features, Vector<int> excludeIndices) Performs the forward pass to get predictions.
Tensor<T> Predict(Tensor<T> features) Makes predictions (alias for Forward).
ValueTuple<Tensor<T>, Tensor<T>, Tensor<T>> PredictWithConfidence(Tensor<T> features, double confidenceLevel) Predicts with confidence intervals based on neighbor variance.
void BuildIndex(Tensor<T> features, Tensor<T> targets) Builds the retrieval index from training features and their targets, so every retrieved neighbour contributes its target embedding (Gorishniy et al.
void ResetState() Resets internal state.
void UpdateParameters(T learningRate) Updates all parameters.