SAINT<T>

Models & Types · AiDotNet.Finance.Risk

SAINT (Self-Attention and Intersample Attention Transformer) for tabular data.

Inheritance: NeuralNetworkBase<T> → FinancialModelBase<T> → RiskModelBase<T> → SAINT<T>

For Beginners

SAINT improves on standard transformers for tabular data by paying attention not just to the relationships between columns (features) but also between rows (samples). This allows it to learn from similar examples in the batch, much like a nearest-neighbor approach but fully learnable.

Example

// Define architecture for tabular risk assessment (50 features, binary classification)
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.OneDimensional,
    taskType: NeuralNetworkTaskType.MultiClassClassification,
    inputSize: 50, outputSize: 2);
            
// Training mode: self-attention over features + intersample attention over rows
var model = new SAINT<double>(architecture);
            
// Parameterless constructor with default 50-feature regression architecture
var defaultModel = new SAINT<double>();

Constructors

Constructor Summary
SAINT() Initializes a new instance of the SAINT model.
SAINT(NeuralNetworkArchitecture<T> architecture, SAINTOptions<T> options, IGradientBasedOptimizer<T, Tensor<T>, Tensor<T>> optimizer, ILossFunction<T> lossFunction)
SAINT(NeuralNetworkArchitecture<T> architecture, string onnxModelPath, SAINTOptions<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 SAINT.
Tensor<T> AdjustForRisk(Tensor<T> action, T riskBudget) Adjusts action for risk.