{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Discovery: native graphs, explicit scores and reconnect\n", "\n", "SDK 0.7 native causal example. Default execution is a synthetic HTTP wire fixture, not a discovery model or scientific benchmark. Explicit live execution requires the qualified ArrowFM causal task; it never substitutes another family. This notebook uses the frozen seed42 full128x4 observational chain/isolate input and retains every uploaded variable. The five-engine causal pack and public Ergodic co-release remain separate gates. No deletion or saved predictions occur.\n" ], "id": "causal-00" }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "from support import notebook_causal_client, causal_table\n", "from welt import CausalResult\n", "import numpy as np\n", "\n", "client = notebook_causal_client()\n", "profile = next((m for m in client.models() if m[\"id\"] == \"arrow\"), None)\n", "task = next((p for p in (profile or {}).get(\"task_profiles\", [])\n", " if p[\"task\"] == \"causal_discovery\"), None)\n", "if not task or not task.get(\"execution_available\"):\n", " raise RuntimeError(\"Qualified ArrowFM discovery is unavailable; no substitution or upload.\")\n", "columns, observations = causal_table()\n", "dataset = client.upload(columns=columns, rows=observations.tolist(), target=None,\n", " name=\"Synthetic discovery SDK notebook\")\n", "job = client.submit_discover(dataset[\"id\"], model=\"arrow\", seed=42)\n", "result = job.result(timeout=120)\n", "assert isinstance(result, CausalResult)\n", "assert result.job_id == job.id\n", "assert result.variables == tuple(columns)\n", "assert result.model_version == task[\"version\"]\n", "assert result.native_graph_type == \"dag\"\n" ], "id": "causal-01" }, { "cell_type": "markdown", "metadata": {}, "source": [ "The native graph and edge scores are separate outputs. ArrowFM decodes its native DAG from the original skeleton and ordering, rather than thresholding the returned edge probabilities. Preserve names, endpoint marks, decoder and model/configuration provenance. Learned edges do not establish causal truth; scores are neither calibrated confidence nor graph posterior probabilities.\n" ], "id": "causal-02" }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "scores = client.causal_scores(result.job_id)\n", "values = np.asarray(scores[\"values\"], dtype=float)\n", "assert scores[\"result_id\"] == result.id\n", "assert scores[\"score_reference\"] == result.score_reference\n", "assert scores[\"variables\"] == list(result.variables)\n", "assert scores[\"score_axes\"] == \"source_row_target_column\"\n", "assert values.shape == (4, 4) and np.isfinite(values).all()\n", "assert ((values >= 0) & (values <= 1)).all()\n", "assert (values.diagonal() == 0).all()\n", "reopened = client.causal_result(result.job_id)\n", "assert reopened.to_dict() == result.to_dict()\n", "assert all(edge[\"u\"] in columns and edge[\"v\"] in columns for edge in result.edge_marks)\n", "operation_id = job.inspect()[\"operation_id\"]\n", "assert operation_id != job.id\n", "events = [e for e in client.usage() if e[\"operation_id\"] == operation_id]\n", "assert events and all(e[\"model_version\"] == result.model_version for e in events)\n", "client.close()\n" ], "id": "causal-03" }, { "cell_type": "markdown", "metadata": {}, "source": [ "Explicit local Ergodic conversion uses a separately installed approved co-release artifact. Welt does not download it. The actual compatible wheel is currently private; absence is shown below and is not counted as successful causal continuation. Conversion accepts only a declared native DAG without graph repair. MixedGraph stores node sets, so always supply the original order when inspecting adjacency. No effect estimate is claimed by this notebook.\n" ], "id": "causal-04" }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "from welt import OptionalDependencyError\n", "\n", "try:\n", " graph = result.to_ergodic()\n", "except OptionalDependencyError:\n", " print(\"Local graph continuation is gated on the approved Ergodic co-release artifact.\")\n", "else:\n", " adjacency, order = graph.to_adjacency(order=list(result.variables))\n", " assert order == list(result.variables)\n", " assert adjacency.shape == (len(columns), len(columns))\n", " assert graph.nodes == frozenset(result.variables)\n" ], "id": "causal-05" }, { "cell_type": "markdown", "metadata": {}, "source": [ "Primary graphs and scores persist until an explicit owned deletion under server quotas. They are separate from seven-day downloadable prediction results. These created synthetic datasets/jobs/results stay retained; reconnect with result.job_id and a fresh Client. Controlled transport validates client plumbing only; live native execution, tenant isolation, restart, resource admission and learned Ergodic identification/estimation need separate evidence.\n" ], "id": "causal-06" } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }