← 返回日报
🌐 机器翻译 · DeepSeek · GitHub

PriorLabs TabPFN


以下是您要求的英文文章翻译为流畅中文的结果,已严格遵循原文结构、格式和术语保留要求。


PriorLabs TabPFN

TabPFN 快速入门交互式笔记本教程 💡

立即使用我们的交互式 Colab 笔记本上手体验!这是感受 TabPFN 的最佳方式,它将引导您完成安装、分类和回归示例。

推荐使用 GPU:为获得最佳性能,请使用 GPU(即使是较旧的、约 8GB 显存的 GPU 也能良好运行;部分大型数据集需要 16GB)。在 CPU 上,仅适用于小型数据集(≲1000 个样本)。没有 GPU?可通过 TabPFN Client 使用我们免费的托管推理服务。

安装

官方安装(pip)

pip install tabpfn

或从源码安装

pip install "tabpfn @ git+https://github.com/PriorLabs/TabPFN.git"

或本地开发安装:首先安装我们开发所用的 uv(建议使用 0.10.0 或更高版本),然后运行:

git clone https://github.com/PriorLabs/TabPFN.git --depth 1
cd TabPFN
uv sync

基本用法

使用我们默认的、完全基于合成数据训练的 TabPFN-2.6 模型:

from tabpfn import TabPFNClassifier, TabPFNRegressor

clf = TabPFNClassifier()
clf.fit(X_train, y_train)  # 首次使用时会下载检查点
predictions = clf.predict(X_test)

reg = TabPFNRegressor()
reg.fit(X_train, y_train)  # 首次使用时会下载检查点
predictions = reg.predict(X_test)

使用其他模型版本(例如 TabPFN-2.5):

from tabpfn import TabPFNClassifier, TabPFNRegressor
from tabpfn.constants import ModelVersion

classifier = TabPFNClassifier.create_default_for_version(ModelVersion.V2_5)
regressor = TabPFNRegressor.create_default_for_version(ModelVersion.V2_5)

完整示例请参见 tabpfn_for_binary_classification.pytabpfn_for_multiclass_classification.pytabpfn_for_regression.py 文件。

使用技巧

根据您的需求选择合适的 TabPFN 实现:

按照以下决策树构建您的模型,并从我们的生态系统中选择合适的扩展。它将引导您回答关于数据、硬件和性能需求的关键问题,从而为您的特定用例找到最佳解决方案。

config:
  theme: 'default'
  themeVariables:
    edgeLabelBackground: 'white'
---
graph LR
    %% 1. 定义颜色方案与样式
    classDef default fill:#fff,stroke:#333,stroke-width:2px,color:#333;
    classDef start_node fill:#e8f5e9,stroke:#43a047,stroke-width:2px,color:#333;
    classDef process_node fill:#e0f2f1,stroke:#00796b,stroke-width:2px,color:#333;
    classDef decision_node fill:#fff8e1,stroke:#ffa000,stroke-width:2px,color:#333;
    style Infrastructure fill:#fff,stroke:#ccc,stroke-width:5px;
    style Unsupervised fill:#fff,stroke:#ccc,stroke-width:5px;
    style Data fill:#fff,stroke:#ccc,stroke-width:5px;
    style Performance fill:#fff,stroke:#ccc,stroke-width:5px;
    style Interpretability fill:#fff,stroke:#ccc,stroke-width:5px;

    %% 2. 定义图结构
    subgraph Infrastructure
        start((Start)) --> gpu_check["GPU available?"];
        gpu_check -- Yes --> local_version["Use TabPFN
(local PyTorch)"]; gpu_check -- No --> api_client["Use TabPFN-Client
(cloud API)"]; task_type["What is
your task?"] end local_version --> task_type api_client --> task_type end_node((Workflow
Complete)); subgraph Unsupervised unsupervised_type["Select
Unsupervised Task"]; unsupervised_type --> imputation["Imputation"] unsupervised_type --> data_gen["Data
Generation"]; unsupervised_type --> tabebm["Data
Augmentation"]; unsupervised_type --> density["Outlier
Detection"]; unsupervised_type --> embedding["Get
Embeddings"]; end subgraph Data data_check["Data Checks"]; model_choice["Samples > 50k or
Classes > 10?"]; data_check -- "Table Contains Text Data?" --> api_backend_note["Note: API client has
native text support"]; api_backend_note --> model_choice; data_check -- "Time-Series Data?" --> ts_features["Use Time-Series
Features"]; ts_features --> model_choice; data_check -- "Purely Tabular" --> model_choice; model_choice -- "No" --> finetune_check; model_choice -- "Yes, 50k-100k samples" --> ignore_limits["Set
ignore_pretraining_limits=True"]; model_choice -- "Yes, >100k samples" --> subsample["Large Datasets Guide
"]; model_choice -- "Yes, >10 classes" --> many_class["Many-Class
Method"]; end

如果您需要将上述 Mermaid 流程图中的英文节点也一并翻译为中文,请告知,我可以为您提供完整的中文版本。

📖 阅读原文 →