Skip to main content
Looking for usage documentation? Check out Classification and KV cache.

TabPFNClassifier.fit

View source
Fit the model. Uploads the training data to the server, which fits the model on it, and returns once the fit has completed. Every call starts a new fit, also on a model with a pending fit. To start a fit without waiting for it, use submit_fit(). The model takes the new fit as soon as the server has accepted it. A fit that fit() polls for, as an ASYNC or thinking-mode one, is then pending until the poll sees it complete: if the poll stops, for a timeout or an interrupt, the model stays pending on the new fit, and wait_for_fit() resumes the wait.
Parameters
Returns
Raises ValueError If the data or the estimator’s parameters are invalid, or the data exceeds the model limits. FitFailedError If the server reports that the fit failed while fit() polled for it. The model is then unfitted. FittedModelNotFoundError If the server no longer has the fit while fit() polls for it. The model is then unfitted. TimeoutError If a fit that fit() polls for has not completed within TABPFN_CLIENT_ASYNC_POLL_TIMEOUT seconds. The model is then pending on the new fit.

TabPFNClassifier.predict

View source
Predict the class labels for the provided input samples. Once the server has accepted the prediction, it replaces the model’s pending prediction, as submit_predict() does. While predict() waits for a prediction the server runs as a background job, the model holds it: if the wait stops, for a timeout or an interrupt, the prediction stays pending, for wait_for_predict() to resume and save_model() to save.
Parameters
Returns
Raises NotFittedError If the model has no fit, or its fit is pending: call wait_for_fit() first. PredictFailedError If the server reports that the prediction failed, in answer to the prediction request or to a poll for it. Another failed request raises RuntimeError, which PredictFailedError subclasses. RefitRequiredError If the fitted model can no longer predict: call fit() again. TimeoutError If a prediction the server runs as a background job has not completed within TABPFN_CLIENT_ASYNC_POLL_TIMEOUT seconds. The model then holds it: call wait_for_predict().

TabPFNClassifier.predict_proba

View source
Predict the probabilities of the classes for the provided input samples. Once the server has accepted the prediction, it replaces the model’s pending prediction, as submit_predict() does. While predict() waits for a prediction the server runs as a background job, the model holds it: if the wait stops, for a timeout or an interrupt, the prediction stays pending, for wait_for_predict() to resume and save_model() to save.
Parameters
Returns
Raises NotFittedError If the model has no fit, or its fit is pending: call wait_for_fit() first. PredictFailedError If the server reports that the prediction failed, in answer to the prediction request or to a poll for it. Another failed request raises RuntimeError, which PredictFailedError subclasses. RefitRequiredError If the fitted model can no longer predict: call fit() again. TimeoutError If a prediction the server runs as a background job has not completed within TABPFN_CLIENT_ASYNC_POLL_TIMEOUT seconds. The model then holds it: call wait_for_predict().

TabPFNClassifier.get_timings

View source
Seconds the server spent on the last fit and the last prediction. Returns {"fit": ..., "predict": ...}:
  • fit: elapsed_s, queue_wait_s, train_set_transform_s, fit_s.
  • predict: test_set_transform_queue_wait_s, test_set_transform_s, predict_queue_wait_s, predict_s. A prediction sent in several requests reports their sum.
Queue wait is time spent waiting for the server to start the work. An entry is None before the first call, while a fit is pending, on a model restored with load_model() from a completed fit, and when the server does not report timings.
Returns

TabPFNClassifier.last_predict_timings

View source
Seconds per stage of the most recent prediction, or None. Returns

TabPFNClassifier.submit_fit

View source
Start fitting the model on the server, without waiting for the fit. Checks and uploads the training data as fit() does, but returns as soon as the server has accepted the fit, which it then runs as a background job, whatever api_mode is. Until wait_for_fit() sees the fit complete, the model is pending: predict() raises NotFittedError, and save_model() saves it as a pending fit, which a later run can load_model() and wait for. The id of the fit is in model_id_ as soon as submit_fit() returns, for logs or support requests.
Parameters
Returns
Raises ValueError If the data or the estimator’s parameters are invalid, or the data exceeds the model limits.

TabPFNClassifier.wait_for_fit

View source
Wait for the server to complete the fit submit_fit() started. Polls the server until the fit has completed, after which the model can predict. A model load_model() restored from a record of a pending fit is waited for the same way. Returns at once, without a request, if the fit has already completed.
Returns
Raises NotFittedError If the model has no fit to wait for. FitFailedError If the server reports that the fit failed. The model is then unfitted. FittedModelNotFoundError If the server does not have the fit, for instance because it was deleted. The model is then unfitted. TimeoutError If the fit has not completed within TABPFN_CLIENT_ASYNC_POLL_TIMEOUT seconds. The model is still pending, so wait_for_fit() can be called again. RuntimeError If polling for the fit fails 4 times in a row with an unexpected error. The model is still pending.

TabPFNClassifier.submit_predict

View source
Start predicting on the server, without waiting for the predictions. Checks and uploads X as predict() does, but returns as soon as the server has accepted the prediction, which it then runs as a background job, whatever api_mode is. wait_for_predict() waits for it and returns the predictions. The model holds one pending prediction: a new submit_predict() or predict() replaces it once the server has accepted the new prediction, and a new fit drops it. save_model() saves it, and a pickled or copied model keeps it; clone() does not.
Parameters
Returns
Raises NotFittedError If the model has no fit, or its fit is pending: call wait_for_fit() first. ValueError If output_type is not "preds" or "probas", X exceeds the model limits or the group columns are invalid. RuntimeError If the server does not run predictions as background jobs. PredictFailedError If the server reports that the prediction failed at once, for example because it could not queue it.

TabPFNClassifier.wait_for_predict

View source
Wait for the pending prediction, and return it. The pending prediction is the one submit_predict() started, or one predict() stopped waiting for. Polls the server until the prediction has completed. Until then the prediction is pending, so a wait that stops can be resumed by calling wait_for_predict() again.
Returns
Raises RuntimeError If no prediction is pending, polling for it fails, or the server no longer has it. In the last case, it is then no longer pending. PredictFailedError If the server reports that the prediction failed. It is then no longer pending. RefitRequiredError If the fitted model can no longer predict: call fit() again. The prediction is then no longer pending. TimeoutError If the prediction has not completed within TABPFN_CLIENT_ASYNC_POLL_TIMEOUT seconds.

Scikit-learn scoring

Inherited score(X, y, sample_weight=None) calls predict and returns mean classification accuracy.