TabPFNClassifier<T>

Models & Types · AiDotNet.NeuralNetworks.Tabular

TabPFN implementation for classification tasks.

Inheritance: TabPFNBase<T> → TabPFNClassifier<T>

For Beginners

TabPFN classification works differently:

  1. First, call SetContext() with your training data
  2. Then, call Predict() with test data
  3. The model uses attention to “learn” from context
  4. No training loop needed - it’s instant!

Example:

How It Works

TabPFNClassifier uses in-context learning for tabular classification. It takes training data as context and makes predictions on test data in a single forward pass, similar to how language models complete text.

Constructors

Constructor Summary
TabPFNClassifier(int numNumericalFeatures, int numClasses, TabPFNOptions<T> options) Initializes a new instance of the TabPFNClassifier class.

Properties

Property Summary
int NumClasses { get; } Gets the number of output classes.

Methods

Method Summary
T ComputeAccuracy(Tensor<T> numericalFeatures, Vector<int> targets, Matrix<int> categoricalIndices) Computes classification accuracy.
T ComputeCrossEntropyLoss(Tensor<T> probabilities, Vector<int> targets) Computes the cross-entropy loss.
T TrainStep(Tensor<T> numericalFeatures, Vector<int> targets, T learningRate, Matrix<int> categoricalIndices) Performs a single training step (for fine-tuning).
Tensor<T> Forward(Tensor<T> numericalFeatures, Matrix<int> categoricalIndices) Performs the forward pass to get class logits.
Tensor<T> PredictProbabilities(Tensor<T> numericalFeatures, Matrix<int> categoricalIndices) Predicts class probabilities using softmax.
Vector<int> Predict(Tensor<T> numericalFeatures, Matrix<int> categoricalIndices) Predicts the most likely class for each sample.
Vector<int> PredictEnsemble(Tensor<T> numericalFeatures, int numEnsembles, Matrix<int> categoricalIndices) Predicts with ensemble averaging over multiple permutations.
void ResetState() Resets internal state.
void SetContext(Tensor<T> features, Vector<int> labels) Sets the context (training) data for in-context learning.
void UpdateParameters(T learningRate) Updates all parameters.