TabNetClassifier<T>
Models & Types · AiDotNet.NeuralNetworks.Tabular
TabNet implementation for classification tasks.
Inheritance: TabNetBase<T> → TabNetClassifier<T>
For Beginners
Use TabNetClassifier when you want to categorize data into different classes (groups) from tabular data.
Example use cases:
- Customer churn prediction (will stay / will leave)
- Fraud detection (legitimate / fraudulent transaction)
- Medical diagnosis (healthy / disease A / disease B / …)
- Credit risk assessment (low / medium / high risk)
Key features:
- Automatic Feature Selection: Learns which features matter for classification
- Interpretability: See which features drove each classification decision
- Multi-class Support: Works for binary (2 classes) or multi-class problems
- Probability Outputs: Returns confidence scores for each class
Basic usage:
How It Works
TabNetClassifier extends the TabNet architecture for predicting discrete class labels. It uses softmax activation on the output layer to produce class probabilities.
Reference: “TabNet: Attentive Interpretable Tabular Learning” (Arik & Pfister, AAAI 2021)
Constructors
| Constructor | Summary |
|---|---|
TabNetClassifier(int inputFeatures, int numClasses, TabNetOptions<T> options) |
Initializes a new instance of the TabNetClassifier class. |
Methods
| Method | Summary |
|---|---|
T ComputeAccuracy(int[] predictions, Tensor<T> targets) |
Computes the accuracy (percentage of correct predictions). |
T ComputeCrossEntropyLoss(Tensor<T> probabilities, Tensor<T> targets) |
Computes the cross-entropy loss for classification. |
T ComputeCrossEntropyLossOneHot(Tensor<T> probabilities, Tensor<T> oneHotTargets) |
Computes cross-entropy loss with one-hot encoded targets. |
T ComputeF1Score(int[] predictions, Tensor<T> targets, int positiveClass) |
Computes the F1 score for binary classification. |
T ComputeTotalLoss(Tensor<T> probabilities, Tensor<T> targets) |
Computes the total loss including sparsity regularization. |
T TrainStep(Tensor<T> input, Tensor<T> targets, T learningRate) |
Performs a single training step. |
Tensor<T> ComputeCrossEntropyGradient(Tensor<T> probabilities, Tensor<T> targets) |
Computes the gradient of cross-entropy loss with softmax. |
Tensor<T> ComputeCrossEntropyGradientOneHot(Tensor<T> probabilities, Tensor<T> oneHotTargets) |
Computes the gradient with one-hot encoded targets. |
Tensor<T> Forward(Tensor<T> input) |
Performs forward pass with softmax activation. |
Tensor<T> ForwardLogits(Tensor<T> input) |
Gets the raw logits without softmax. |
Tensor<T> PredictProbabilities(Tensor<T> input) |
Gets class probabilities for each sample. |
int[] Predict(Tensor<T> input) |
Predicts class labels (indices of highest probability classes). |