FTTransformerRegression<T>
Models & Types · AiDotNet.NeuralNetworks.Tabular
FT-Transformer implementation for regression tasks.
Inheritance: FTTransformerBase<T> → FTTransformerRegression<T>
For Beginners
Use this model when you want to predict continuous numbers (like house prices, temperatures, stock returns, etc.).
How it works:
- Features are tokenized and processed by transformer layers
- The [CLS] token captures information from all features
- A linear layer maps the [CLS] representation to the output value(s)
Example:
How It Works
FTTransformerRegression applies the FT-Transformer architecture to regression problems. It uses the [CLS] token output with a linear regression head to predict continuous values.
Constructors
| Constructor | Summary |
|---|---|
FTTransformerRegression(int numNumericalFeatures, int outputDimension, FTTransformerOptions<T> options) |
Initializes a new instance of the FTTransformerRegression class. |
Properties
| Property | Summary |
|---|---|
int OutputDimension { get; } |
Gets the output dimension (number of target values to predict). |
Methods
| Method | Summary |
|---|---|
T ComputeMAELoss(Tensor<T> predictions, Tensor<T> targets) |
Computes the Mean Absolute Error (MAE) loss. |
T ComputeMAPE(Tensor<T> numericalFeatures, Tensor<T> targets, Matrix<int> categoricalIndices) |
Computes the Mean Absolute Percentage Error (MAPE). |
T ComputeMSELoss(Tensor<T> predictions, Tensor<T> targets) |
Computes the Mean Squared Error (MSE) loss. |
T ComputeR2Score(Tensor<T> numericalFeatures, Tensor<T> targets, Matrix<int> categoricalIndices) |
Computes the R² score (coefficient of determination). |
T ComputeRMSE(Tensor<T> numericalFeatures, Tensor<T> targets, Matrix<int> categoricalIndices) |
Computes the Root Mean Squared Error (RMSE). |
T TrainStep(Tensor<T> numericalFeatures, Tensor<T> targets, T learningRate, Matrix<int> categoricalIndices) |
Performs a single training step using MSE loss. |
Tensor<T> Forward(Tensor<T> numericalFeatures) |
Performs the forward pass with numerical features only. |
Tensor<T> Forward(Tensor<T> numericalFeatures, Matrix<int> categoricalIndices) |
Performs the forward pass to get predictions. |
Tensor<T> Predict(Tensor<T> numericalFeatures) |
Alias for Forward with numerical features only. |
Tensor<T> Predict(Tensor<T> numericalFeatures, Matrix<int> categoricalIndices) |
Alias for Forward - makes predictions on the input data. |
void ResetState() |
Resets internal state. |
void UpdateParameters(T learningRate) |
Updates all parameters including the regression head. |