WeltPython SDK

From a DataFrame
to a prediction.

Your first prediction

Python 3.11–3.13 · SDK 0.7.1

sh
python -m pip install "welt-client[parquet]==0.7.1"
2   Connect your workspace

Open Account in Welt, create a key with Allow writes, fits and predictions, then enter it at this hidden prompt. Keep keys out of saved code.

python
import getpass
import os

os.environ["WELT_API_KEY"] = getpass.getpass("Welt API key: ")

3   Train, predict and evaluateFull walkthrough ↗
Download, inspect and split the real research table · included in Copy
python
from pathlib import Path
from tempfile import mkdtemp
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score, classification_report
from welt import Client, Classifier

# 1. Get a real table from Welt's research inventory.
dataset_id = "asset-d839644b6de36fc5cafdda18c5daeca3"
version = "d839644b6de36fc5cafdda18c5daeca3284a5ce8bb6169aff2fcb3fbb4a12021"
path = Path(mkdtemp(prefix="welt-iris-")) / "iris.parquet"
with Client() as client:
    info = client.research_dataset(dataset_id)
    print("Dataset:", info["name"], "— License:", info["license"])
    for notice in info["license_notices"]:
        print(notice)
    client.download_research_dataset(dataset_id, path, version=version)
data = pd.read_parquet(path)
target = "__target__#0"  # The target recorded in this research snapshot.

# 2. Look at the rows before modelling.
print(data.head())
print("Rows and columns:", data.shape)
data.info()
print(data[target].value_counts())

# 3. Set aside test rows before fitting; never train on their answers.
split = train_test_split(
    data, test_size=0.2, random_state=9, stratify=data[target])
python
train = split[0]  # Labelled pandas DataFrame from the split.
print(train.head())
test = split[1]
query = test.drop(columns=target)
y_test = test[target]
print("Training rows:", len(train), "— Test rows:", len(test))

# 4. Create a model and train it on the training table.
model = Classifier(model="tabicl-v2", random_state=9)
model.fit(train, target=target)

# 5. Predict the held-out rows, without passing their target column.
predictions = model.predict(query)
print(pd.DataFrame({"actual": y_test.to_numpy(), "predicted": predictions}).head())

# 6. Compare predictions with the answers we kept aside.
print("Test accuracy:", accuracy_score(y_test, predictions))
print(classification_report(y_test, predictions, zero_division=0))
print("Keep this predictor ID:", model.predictor_id_)

Read the resultCompare actual and predicted labels, then inspect your test accuracy and per-class report. All 30 test rows are evaluated.

Fit uploads the training table into your private workspace. Predict executes remotely. Keep your predictor ID to reuse the fit; no particular score is promised.

Use your own table ↗

Declare the target and hold back test rows.

Reopen your predictor ↗

Predict again without a new fit.

Learn in a notebook ↗

Real tables and clear steps.

Documentation
Search SDK 0.7.1

Search this SDK version by task, method or error.