WeltPython SDK
Products: switch from Welt to another product
Open console

Get startedKeep your predictor and inspect usage

← All notebooks

Static notebook preview · outputs are cleared. Open in Colab or download the notebook to run the cells. Colab setup

python
!pip install "welt-client[parquet]"

Keep your predictor and inspect usage

Run the installation cell first, connect your workspace, then run the remaining cells in order. These are real hosted requests: fitting retains a private training dataset and predictor. No extra helper file is needed. Outputs are deliberately not saved in this source.

python
from welt import Client

with Client() as client:
    client.connect()

First learn the same real Iris classification workflow. Then reuse its fitted predictor and inspect operation metadata. Check Workspace → Billing for available credits and spend caps before running: modelling and research downloads may consume credits. The current public rate card applies a five-credit minimum to priced modelling operations and 25 credits per research download; check the latest offers in Billing or client.pricing(). Several lifecycle events can describe one operation and repeat its nullable credits/rate_card_version accounting fields; do not add them across events. credits:null means unpriced, not a guarantee of free future runs.

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"
path = Path(mkdtemp(prefix="welt-iris-")) / "iris.parquet"
with Client() as client:
    info = client.research_dataset(dataset_id)
    print("Dataset:", info["name"])
    client.download_research_dataset(dataset_id, path)
data = pd.read_parquet(path)
target = "target"  # The outcome column in this table.
python
# 2. Look at the rows before modelling.
print(data.head())
print("Rows and columns:", data.shape)
data.info()
print(data[target].value_counts())
python
# 3. Set aside test rows before fitting; never train on their answers.
train, test = train_test_split(
    data, test_size=0.2, random_state=9, stratify=data[target])
query = test.drop(columns=target)
y_test = test[target]
print("Training rows:", len(train), "— Test rows:", len(test))
python
# 4. Create a model and train it on the training table.
model = Classifier(model="tabicl-v2", random_state=9)
model.fit(train, target=target)
python
# 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())
python
# 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_)

Now reuse the same fit. A predictor ID is an identity, not an API key or locally executable weights.

python
# Reuse the fit we already made: no new training upload or fit.
from welt import Classifier, Client
reopened = Classifier.from_predictor(model.predictor_id_)
repeat = reopened.predict(query)
print("Same pinned version:", reopened.model_version_ == model.model_version_)
print("Same predictions:", (predictions == repeat).all())
with Client() as client:
    metadata = client.predictor(model.predictor_id_)
    events = client.usage()
print("Model version:", metadata["model_version"])
operations = {event["operation_id"] for event in events
              if event.get("predictor_id") == model.predictor_id_}
print("Recorded operations for this predictor:", len(operations))

# One accounting view per operation; lifecycle events repeat these fields.
accounting = {event["operation_id"]: {
    "credits": event.get("credits"),
    "rate_card_version": event.get("rate_card_version"),
} for event in events if event.get("predictor_id") == model.predictor_id_}
print("Operation accounting:", accounting)
Documentation

Search SDK 0.13.1

Search this SDK version by task, method or error.