TabTransformer<T>
Models & Types · AiDotNet.Finance.Risk
TabTransformer model for tabular data, using transformers for categorical features.
Inheritance: NeuralNetworkBase<T> → FinancialModelBase<T> → RiskModelBase<T> → TabTransformer<T>
For Beginners
TabTransformer applies the power of Transformers (like BERT/GPT) specifically to the categorical parts of your data (e.g., “Sector”, “Country”, “Rating”). It learns deep contextual embeddings for these categories before combining them with numerical data.
Example
// Define architecture for categorical-rich tabular risk data (10 features, single output)
var architecture = new NeuralNetworkArchitecture<double>(
inputType: InputType.OneDimensional,
taskType: NeuralNetworkTaskType.Regression,
inputSize: 10, outputSize: 1);
// Training mode: transformer contextualizes categorical embeddings before MLP
var model = new TabTransformer<double>(architecture);
// Parameterless constructor with default architecture
var defaultModel = new TabTransformer<double>();
Constructors
| Constructor | Summary |
|---|---|
TabTransformer() |
Initializes a new instance of the TabTransformer model. |
TabTransformer(NeuralNetworkArchitecture<T> architecture, TabTransformerOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) |
|
TabTransformer(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, TabTransformerOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction) |
Initializes a new instance from ONNX. |
Methods
| Method | Summary |
|---|---|
T CalculateRisk(Tensor<T> input) |
Calculates risk using TabTransformer. |
Tensor<T> AdjustForRisk(Tensor<T> action, T riskBudget) |
Adjusts action for risk. |