Skip to main content
Documentation

Deployments

A deployment exposes one target of a finished analysis as an authenticated REST endpoint. Deploying does not recompute or copy anything: the endpoint reads the model your analysis already discovered and evaluates it in-process, so predictions are fast and always come from exactly the model you reviewed.

Creating a deployment

Open the notebook of a finished analysis and use the Deploy as REST endpoint action (the rocket icon) in the bar above the notebook. Pick the target you want to serve and, optionally, a name. The dialog then shows the endpoint URL, the input keys the model expects, the prediction interval derived from held-out data, and a copyable example call. All your deployments are listed on the Deployments page, where you can inspect each one, try it interactively, and delete it again.

The predict endpoint

Send a POST request with one row of input values. Authenticate with a dfat_ API token minted in Project settings → API Tokens (a signed-in session token works too). See API Authentication.
curl
curl -X POST 'https://diafunc.com/api/v1/deployments/<deploymentId>/predict' \
  -H 'Authorization: Bearer dfat_…' \
  -H 'Content-Type: application/json' \
  -d '{
  "inputs": {
    "alcohol": 11.2,
    "sugar": 2.5
  }
}'
Python
import requests

response = requests.post(
    "https://diafunc.com/api/v1/deployments/<deploymentId>/predict",
    headers={"Authorization": "Bearer dfat_…"},
    json={"inputs": {"alcohol": 11.2, "sugar": 2.5}},
)
result = response.json()
print(result["prediction"], result["confidence"], result["predictionId"])
JavaScript
const response = await fetch(
  "https://diafunc.com/api/v1/deployments/<deploymentId>/predict", {
    method: "POST",
    headers: {
      "Authorization": "Bearer dfat_…",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ inputs: { alcohol: 11.2, sugar: 2.5 } }),
  });
const { prediction, confidence, predictionId } = await response.json();
The response contains the predicted value, a prediction interval, and a predictionId you can use later to report the realized outcome:
Response
{
  "target": "quality",
  "prediction": 6.4,
  "confidence": {
    "lower": 5.8,
    "upper": 7.0,
    "halfWidth": 0.6,
    "level": 0.9,
    "method": "empirical_p5_p95",
    "nHeldOut": 800,
    "expectedCoverage": 0.9
  },
  "predictionId": "5f1f6c2e-…"
}
The interval is computed from the residuals of held-out rows during the analysis, from their 5th to their 95th percentile (level: 0.9, method: "empirical_p5_p95"), on the nHeldOut rows. expectedCoverage is the share of new rows like those the interval can be expected to hold, 0.9 × (n − 1) / (n + 1): 0.74 on 10 held-out rows, 0.88 on 100. Plan with that figure: on many held-out rows nine in ten actual values lie inside the interval, on few rows fewer do. When those residual statistics are not available, confidence is null. Numeric-looking strings in inputs are coerced to numbers; other strings are passed through unchanged.

Closing the loop: record outcomes

Every prediction is logged. Once the real value is known, report it back with the predictionId from the predict response:
Record an outcome
curl -X POST 'https://diafunc.com/api/v1/deployments/<deploymentId>/predictions/<predictionId>/outcome' \
  -H 'Authorization: Bearer dfat_…' \
  -H 'Content-Type: application/json' \
  -d '{ "actual": 6.0 }'
Recorded outcomes feed the per-deployment performance report (mean absolute error, R², and the recent predictions with their actuals), shown in the expanded row on the Deployments page and available as GET /api/v1/deployments/<deploymentId>/performance. MAE and R² appear once at least two outcomes have been recorded. You can also record outcomes directly in the performance table of the Deployments page.

Scope and behavior

A deployment serves exactly one target of one analysis and is private to your account. Deleting a deployment removes the endpoint; the analysis and its model are untouched. The prediction is always a single numeric value per call, with one input row per request.

What next?