TabMClassifier<T>
Models & Types ยท AiDotNet.NeuralNetworks.Tabular
TabM implementation for classification tasks.
Inheritance: TabMBase<T> โ TabMClassifier<T>
For Beginners
Use this model when you want to classify data into categories with the benefits of an ensemble (multiple models voting).
How predictions work:
- Input passes through shared layers with per-member modulation
- Each ensemble member produces class logits
- Logits are averaged across members
- Softmax converts to probabilities
Benefits over single models:
- Reduced overfitting through ensemble averaging
- Better calibrated probability estimates
- More robust to noisy features
- Comparable speed to single models (parameter sharing)
Example:
How It Works
TabMClassifier uses the TabM architecture with BatchEnsemble layers for multi-class classification. It averages predictions across ensemble members and uses softmax for probability outputs.
Constructors
| Constructor | Summary |
|---|---|
TabMClassifier() |
Initializes a new instance of the TabMClassifier class with default configuration. |
TabMClassifier(int numFeatures, int numClasses, TabMOptions<T> options) |
Initializes a new instance of the TabMClassifier class. |
Properties
| Property | Summary |
|---|---|
int NumClasses { get; } |
Gets the number of output classes. |
Methods
| Method | Summary |
|---|---|
T ComputeAccuracy(Tensor<T> features, int[] targets) |
Computes classification accuracy. |
T ComputeCrossEntropyLoss(Tensor<T> probabilities, int[] targets) |
Computes the cross-entropy loss. |
T ComputeF1Score(Tensor<T> features, int[] targets) |
Computes the macro F1 score across all classes. |
T TrainStep(Tensor<T> features, int[] targets, T learningRate) |
Performs a single training step. |
Tensor<T> Forward(Tensor<T> features) |
Performs the forward pass to get class logits (per member). |
Tensor<T> PredictProbabilities(Tensor<T> features) |
Predicts class probabilities (averaged across ensemble members). |
Vector<T> GetPredictiveUncertainty(Tensor<T> features) |
Gets predictive uncertainty as the entropy of the averaged predictions. |
int[] Predict(Tensor<T> features) |
Predicts the most likely class for each sample. |
void ResetState() |
Resets internal state. |
void UpdateParameters(T learningRate) |
Updates all parameters including the classification head. |