Skip to content

classifier

TabPFNClassifier class.

Example

import sklearn.datasets
from tabpfn import TabPFNClassifier

model = TabPFNClassifier()

X, y = sklearn.datasets.load_iris(return_X_y=True)

model.fit(X, y)
predictions = model.predict(X)

TabPFNClassifier

Bases: ClassifierMixin, BaseEstimator

TabPFNClassifier class.

class_counts_ instance-attribute

class_counts_: NDArray[Any]

The number of classes per class found in the target data during fit().

classes_ instance-attribute

classes_: NDArray[Any]

The unique classes found in the target data during fit().

config_ instance-attribute

config_: InferenceConfig

The configuration of the loaded model to be used for inference.

device_ instance-attribute

device_: device

The device determined to be used.

executor_ instance-attribute

executor_: InferenceEngine

The inference engine used to make predictions.

feature_names_in_ instance-attribute

feature_names_in_: NDArray[Any]

The feature names of the input data.

May not be set if the input data does not have feature names, such as with a numpy array.

forced_inference_dtype_ instance-attribute

forced_inference_dtype_: _dtype | None

The forced inference dtype for the model based on inference_precision.

inferred_categorical_indices_ instance-attribute

inferred_categorical_indices_: list[int]

The indices of the columns that were inferred to be categorical, as a product of any features deemed categorical by the user and what would work best for the model.

interface_config_ instance-attribute

interface_config_: ModelInterfaceConfig

Additional configuration of the interface for expert users.

label_encoder_ instance-attribute

label_encoder_: LabelEncoder

The label encoder used to encode the target variable.

n_classes_ instance-attribute

n_classes_: int

The number of classes found in the target data during fit().

n_features_in_ instance-attribute

n_features_in_: int

The number of features in the input data used during fit().

n_outputs_ instance-attribute

n_outputs_: Literal[1]

The number of outputs the model has. Only 1 for now

preprocessor_ instance-attribute

preprocessor_: ColumnTransformer

The column transformer used to preprocess the input data to be numeric.

use_autocast_ instance-attribute

use_autocast_: bool

Whether torch's autocast should be used.

fit

fit(X: XType, y: YType) -> Self

Fit the model.

Parameters:

Name Type Description Default
X XType

The input data.

required
y YType

The target variable.

required

predict

predict(X: XType) -> ndarray

Predict the class labels for the provided input samples.

Parameters:

Name Type Description Default
X XType

The input samples.

required

Returns:

Type Description
ndarray

The predicted class labels.

predict_proba

predict_proba(X: XType) -> ndarray

Predict the probabilities of the classes for the provided input samples.

Parameters:

Name Type Description Default
X XType

The input data.

required

Returns:

Type Description
ndarray

The predicted probabilities of the classes.