TabRClassifier<T>
Models & Types ยท AiDotNet.NeuralNetworks.Tabular
TabR implementation for classification tasks.
Inheritance: TabRBase<T> โ TabRClassifier<T>
For Beginners
TabR for classification works like having a smart assistant who remembers all past examples and uses them to help classify new inputs.
Prediction process:
- Encode the input features
- Find similar training samples (neighbors)
- Use attention to aggregate neighbor information
- Combine with the encoded input
- Predict class probabilities
Example:
How It Works
TabRClassifier uses retrieval-augmented predictions for classification. It finds similar training samples and uses their information along with a neural network to make class predictions.
Constructors
| Constructor | Summary |
|---|---|
TabRClassifier() |
Initializes a new instance of the TabRClassifier class with default configuration. |
TabRClassifier(int numFeatures, int numClasses, TabROptions<T> options) |
Initializes a new instance of the TabRClassifier class. |
Properties
| Property | Summary |
|---|---|
int NumClasses { get; } |
Gets the number of output classes. |
Methods
| Method | Summary |
|---|---|
List<List<ValueTuple<int, T>>> GetPredictionExplanations(Tensor<T> features) |
Gets interpretability information: which neighbors influenced each prediction. |
T ComputeAccuracy(Tensor<T> features, int[] targets) |
Computes classification accuracy. |
T ComputeCrossEntropyLoss(Tensor<T> probabilities, int[] targets) |
Computes the cross-entropy loss. |
T TrainStep(Tensor<T> features, int[] 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 class logits. |
Tensor<T> PredictProbabilities(Tensor<T> features) |
Predicts class probabilities. |
int[] Predict(Tensor<T> features) |
Predicts the most likely class for each sample. |
void BuildIndex(Tensor<T> features, int[] labels) |
Builds the retrieval index from training features and their class labels, so every retrieved neighbour contributes its label embedding (Gorishniy et al. |
void ResetState() |
Resets internal state. |
void UpdateParameters(T learningRate) |
Updates all parameters. |