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

Pass hyper params from client #21

Merged
merged 6 commits into from
May 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Pass hyper params from client
SamuelGabriel committed May 4, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit a3f2cfb0cbdb259ab7e31b6534c539844ca72f10
13 changes: 10 additions & 3 deletions tabpfn_client/client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import annotations

import traceback
from pathlib import Path
import httpx
import logging
@@ -96,7 +99,7 @@ def upload_train_set(self, X, y) -> str:
train_set_uid = response.json()["train_set_uid"]
return train_set_uid

def predict(self, train_set_uid: str, x_test):
def predict(self, train_set_uid: str, x_test, tabpfn_config: dict | None=None):
"""
Predict the class labels for the provided data (test set).

@@ -115,9 +118,14 @@ def predict(self, train_set_uid: str, x_test):

x_test = common_utils.serialize_to_csv_formatted_bytes(x_test)

params = {"train_set_uid": train_set_uid}

if tabpfn_config is not None:
params["tabpfn_config"] = json.dumps(tabpfn_config, default=lambda x: x.to_dict())

response = self.httpx_client.post(
url=self.server_endpoints.predict.path,
params={"train_set_uid": train_set_uid},
params=params,
files=common_utils.to_httpx_post_file_format([
("x_file", "x_test_filename", x_test)
])
@@ -198,7 +206,6 @@ def try_connection(self) -> bool:

except httpx.ConnectError as e:
logger.error(f"Failed to connect to the server with error: {e}")
import traceback
traceback.print_exc()
found_valid_connection = False

70 changes: 0 additions & 70 deletions tabpfn_client/remote_tabpfn_classifier.py

This file was deleted.

13 changes: 3 additions & 10 deletions tabpfn_client/service_wrapper.py
Original file line number Diff line number Diff line change
@@ -177,16 +177,9 @@ def fit(self, X, y) -> None:

self.last_train_set_uid = self.service_client.upload_train_set(X, y)

def predict(self, X):
def predict(self, X, config=None):
return self.service_client.predict(
train_set_uid=self.last_train_set_uid,
x_test=X
x_test=X,
tabpfn_config=config
)

def predict_proba(self, X):
return self.service_client.predict_proba(
train_set_uid=self.last_train_set_uid,
x_test=X
)


Loading
Loading