Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save an ICL tuned model #106

Open
miraculixx opened this issue Jan 9, 2025 · 4 comments
Open

save an ICL tuned model #106

miraculixx opened this issue Jan 9, 2025 · 4 comments
Labels
documentation Improvements or additions to documentation

Comments

@miraculixx
Copy link

How can a fitted model be saved? For example, scikit learn models can generally be exported to disk by using joblib or cloudpickle as noted here

Thanks for the amazing work.

@LennartPurucker
Copy link
Collaborator

We had a similar decision on our Discord before, take a look at https://discord.com/channels/1285598202732482621/1316254428654866462 and let me know if it works for you!

@LennartPurucker LennartPurucker added the documentation Improvements or additions to documentation label Jan 9, 2025
@LennartPurucker
Copy link
Collaborator

In summary from the Discord discussion, you can save the model with pickle as expected:

from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
import pickle
from tabpfn import TabPFNClassifier

# Load data
X, y = load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)

# Train classifier
classifier = TabPFNClassifier(device='cpu')
classifier.fit(X_train, y_train)

# Save the trained classifier to a file
with open('tabpfn_classifier.pkl', 'wb') as f:
    pickle.dump(classifier, f)

# Can be in a separate code
# Load the classifier from the file
with open('tabpfn_classifier.pkl', 'rb') as f:
    loaded_classifier = pickle.load(f)

# Predict
y_pred, p_pred = loaded_classifier.predict(X_test)

@noahho
Copy link
Collaborator

noahho commented Jan 10, 2025

I'd keep this open until we've properly documented it @LennartPurucker right?

@LennartPurucker
Copy link
Collaborator

Mhm, we are not diverging from the default, so I do not know if we need extra documentation.
Nevertheless, we could clarify what saving a fitted TabPFN model even means and the alternatives, such as KV caching.

Let us keep it open for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants