# Model (/docs/nodes/model)



The **Model** node brings a statistical model into the flow. It computes features from the payload, scores them and writes the result. The model runs in-process from its coefficients, or remotely at an inference endpoint.

## When to use it [#when-to-use-it]

* Probability of default, churn or fraud from a model trained elsewhere (a PMML `RegressionModel` imports into it).
* A model you serve yourself: send `{ features }` and read a score from the answer.

## How it works [#how-it-works]

<Diagram node="model" kind="anatomy" />

1. Every **feature** expression is computed from the payload and variables.
2. **Linear / logistic:** `score = intercept + sum(coefficient x feature)`. Logistic also yields `probability = 1 / (1 + e^-score)`. Non-numeric features are rejected; booleans count as 1 or 0.
3. **Endpoint:** the features are posted as `{ features }` and the score is read at the configured path of the answer.
4. With a **threshold**, the result also says whether it was reached (`positive`): the probability for logistic, the score otherwise.

## Ports [#ports]

| Port   | Taken when                           |
| ------ | ------------------------------------ |
| `Next` | Always, after the result is written. |

## Configuration [#configuration]

| Field                      | What it does                                                                                                                                                                                 |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name                       | Label shown on the canvas and in the trace.                                                                                                                                                  |
| Kind                       | `linear`, `logistic` or `endpoint`.                                                                                                                                                          |
| Features                   | Name to expression, for each input of the model.                                                                                                                                             |
| Intercept and coefficients | For linear and logistic. Each coefficient needs a feature of the same name.                                                                                                                  |
| URL, auth, score path      | For endpoint: where to post, the credential, and the dotted path of the score in the answer (`prediction.score`). Timeout, retries and on-error work as in [API call](/docs/nodes/api-call). |
| Threshold                  | Optional. Adds `positive` to the result.                                                                                                                                                     |
| Store result in            | The variable that receives the result.                                                                                                                                                       |

## What it writes [#what-it-writes]

An object under your variable: `{ score }`, plus `probability` for logistic and `positive` when a threshold is set. The trace keeps the features that were scored.

## In a real flow [#in-a-real-flow]

<Diagram node="model" kind="example" />

A logistic model estimates default risk. A condition on `positive` sends risky applicants to manual review; the probability is returned either way.

## When it fails [#when-it-fails]

* A feature is not a number: `VALIDATION_FAILED`.
* Endpoint unreachable, blocked address or no number at the score path: `UPSTREAM_FAILED` or `BLOCKED_URL`, unless on-error is set to continue with a fallback.
* A coefficient without a feature is an error; a feature without a coefficient is a warning, because it is ignored.

## Good to know [#good-to-know]

* The Model node has a single **Next** port, even for an endpoint: a failure with a fallback continues down Next.

## Related [#related]

* [Scorecard](/docs/nodes/scorecard)
* [API call](/docs/nodes/api-call)
