{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Regression: your DataFrame, a reusable predictor\n", "\n", "SDK 0.7. Download this notebook and its matching support.py into the same directory. Restart/run all. Default mode is controlled synthetic HTTP transport, not a foundation model or scientific benchmark. Explicit live mode makes a hosted fit/predict and retains its synthetic state. No fallback, deletion or saved prediction output. The frozen recipe is seed42, 128 training rows, four features and 32 query rows. Read README.md before live use.\n" ], "id": "regression-0" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Build separate training and query tables\n", "\n", "The training table includes the explicit target. Query rows include features only. The helper provides the documented frozen recipe and keeps fixture plumbing out of the public estimator API.\n" ], "id": "regression-1" }, { "cell_type": "code", "metadata": {}, "source": [ "from support import estimator_transport, regression_table\n", "import pandas as pd\n", "import numpy as np\n", "from welt import Regressor\n", "\n", "columns, values, target, query_values = regression_table()\n", "train = pd.DataFrame(values, columns=columns)\n", "train[\"target\"] = target\n", "query = pd.DataFrame(query_values, columns=columns)\n" ], "execution_count": null, "outputs": [], "id": "regression-2" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Fit, predict and reopen\n", "\n", "Choose `Regressor` explicitly. `fit(train, target=\"target\")` excludes the named target from features. Fit uploads and waits for remote preparation; prediction executes remotely. In default mode the context below installs only the controlled transport. In live mode the same public SDK calls run against the configured service.\n" ], "id": "regression-3" }, { "cell_type": "code", "metadata": {}, "source": [ "with estimator_transport():\n", " model = Regressor(model=\"tabicl-v2\", random_state=42)\n", " model.fit(train, target=\"target\")\n", " predictions = model.predict(query)\n", " assert predictions.shape == (32,)\n", " pinned_version = model.model_version_\n", " reopened = Regressor.from_predictor(model.predictor_id_)\n", " repeat = reopened.predict(query[columns[::-1]])\n", " assert reopened.model_version_ == pinned_version\n", " assert np.isfinite(predictions).all()\n", " np.testing.assert_allclose(predictions, repeat, atol=1e-5, rtol=1e-5)\n", " details = model.predict_details(query)\n", " assert details[\"classes\"] is None and details[\"probabilities\"] is None\n", "print(type(predictions).__name__, predictions.shape)\n" ], "execution_count": null, "outputs": [], "id": "regression-4" }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Read the result\n", "\n", "Expected output contract: `ndarray (32,)`, one result per query row in order. Classification probabilities use `classes_` order and are not calibrated confidence. Regression returns finite mean points in target units, without class probabilities or calibrated intervals. Reopening preserves task/model/configuration/version/seed and makes no new fit or training upload; this does not force a worker restart. Keep `predictor_id_` as experiment metadata. Local timeout preserves durable work: reconnect by job ID instead of refitting. Sources contain no execution results.\n" ], "id": "regression-5" } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.11" } }, "nbformat": 4, "nbformat_minor": 5 }