Metadata-Version: 2.5
Name: tabapi
Version: 0.2.0
Summary: scikit-learn-style Python client for tabular foundation models (TabICL) served over HTTP
Project-URL: Homepage, https://probabl.ai
Author: Probabl
License-Expression: BSD-3-Clause
License-File: LICENSE
Keywords: api-client,foundation-model,in-context-learning,scikit-learn,tabicl,tabular
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: requests>=2.31.0
Requires-Dist: scikit-learn>=1.3.0
Provides-Extra: test
Requires-Dist: pytest>=8.0; extra == 'test'
Description-Content-Type: text/markdown

# tabapi

A scikit-learn-style Python client for tabular foundation models (TFMs) such as
[TabICL](https://github.com/soda-inria/tabicl), served over HTTP.

TFMs predict by in-context learning: there is no training loop on your machine.
`tabapi` sends your labelled rows to a TabAPI server, which runs the model, and
gives you back predictions through the familiar `fit` / `predict` /
`predict_proba` interface. You don't need torch or a GPU locally.

> **Status: alpha.** The API may change between minor versions. You need access
> to a running TabAPI server.

## Install

```bash
pip install tabapi
```

Requires Python 3.10+.

## Quickstart

```python
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from tabapi import TabAPIClassifier

X, y = load_breast_cancer(return_X_y=True, as_frame=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

clf = TabAPIClassifier(base_url="https://your-tabapi-server.example.com")
clf.fit(X_train, y_train)          # local: checks and keeps the training data
y_pred = clf.predict(X_test)
proba = clf.predict_proba(X_test)
print(clf.score(X_test, y_test))
```

For a numeric target, `TabAPIRegressor` works the same way; `predict` returns
floats (the mean of TabICL's predictive distribution):

```python
from tabapi import TabAPIRegressor

reg = TabAPIRegressor(base_url="https://your-tabapi-server.example.com")
reg.fit(X_train, y_train)
y_pred = reg.predict(X_test)
```

Both are regular scikit-learn estimators, so they work with
`cross_val_score`, `Pipeline`, `clone`, and so on.

The server is stateless. As with a local TabICL estimator, `fit` makes no
network call: it keeps the training data, and each `predict` or
`predict_proba` sends it along with the rows to predict. So a fitted
estimator, and its pickle, contain the training data, and connection or
authentication errors show up at the first `predict`.

Client 0.2 needs a 0.2 server; client 0.1.x works with server 0.1.x.

## Authentication

If the server requires a bearer token, pass `token=...` or set the
`TABAPI_API_TOKEN` environment variable. The environment variable is read at
request time and is never stored on the estimator, so it does not end up in a
pickled model.

## Retries

Requests the server could not take (busy server, proxy with no healthy backend)
are retried with exponential backoff, honouring `Retry-After`. Tune this with
`max_retries` and `backoff_factor`, or turn it off with `max_retries=0`.

## Upgrading from 0.1

0.2 is a breaking release, and needs a 0.2 server:

- The server is stateless: `fit` no longer calls the server, and every
  `predict` sends the training data. There is no `model_id` any more.
- `target_name` is gone: features and labels travel as separate files.
- `TabAPIClient` is now private (`tabapi._client`). Use `TabAPIClassifier`
  or `TabAPIRegressor`, or call the HTTP API directly.
- New: `TabAPIRegressor`.

Client 0.1.x keeps working with server 0.1.x.

## License

BSD-3-Clause.
