<div class="section-label"><span class="num">03</span> PSR</div>
<div class="section-title"><em>Partial-sample regression</em> at thresholds you choose.</div>
`POST /psr` identifies a relevant subset of observations and forms a relevance-weighted forecast. When the subset is the full sample, the result converges toward classical linear regression. That is the hosted counterpart of [[Functions/Predict|Predict]].
Use PSR when the attribute set and thresholds are already fixed. For primary analysis, prefer [[API/Prediction Engine/Grid|Grid]].
**Call:** `POST /psr`
**Auth:** `x-api-key` header + `access_id` in the body
**Returns:** [[API/Prediction Engine/Results#Task receipt|task receipt]] — then [[API/Prediction Engine/Results|GET /results]]
## Signature
```http
POST https://api.csanalytics.io/v2/prediction-engine/psr
```
Required JSON body (basic spec):
```text
{
access_id, # user access id
y, # outcomes, N × 1
X, # attributes, N × K
theta # circumstances, 1 × K
}
```
## Quick start
The operation below is loaded live from the v2 OpenAPI spec.
```openapi
spec: basic
path: /psr
method: post
```
```python
import json
import requests
url = "https://api.csanalytics.io/v2/prediction-engine/psr"
payload = {
"access_id": "CSA_ACCESS_ID",
"y": [[18.8], [2.3], [3.0], [6.7], [15.2], [20.9], [4.0]],
"X": [
[25.0, 2.0, 76.0, 53.7, 23.1],
[29.0, 1.0, 78.0, 39.1, 5.7],
[32.0, 2.0, 77.0, 54.1, 5.3],
[30.0, 5.0, 82.0, 68.7, 8.7],
[24.0, 1.0, 69.0, 51.0, 20.3],
[25.0, 2.0, 79.0, 50.2, 20.0],
[35.0, 3.0, 80.0, 51.5, 9.4],
],
"theta": [[24.0, 5.0, 81.0, 60.0, 11.0]],
}
headers = {
"x-api-key": "CSA_API_KEY",
"Content-Type": "application/json",
"Connection": "keep-alive",
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
```
A 200 response is the task receipt: <span class="mono">job_id</span> and <span class="mono">job_code</span>.
## Custom settings
The extended spec adds a threshold (single number or array) plus PSR options.
```openapi
spec: extended
path: /psr
method: post
```
When <span class="mono">verify_missing_data</span> is <span class="mono">true</span>, mean and covariance use only complete rows. When <span class="mono">false</span>, they use nan-aware methods. In both modes, rows with missing values receive zero prediction weight.
```python
payload = {
"access_id": "CSA_ACCESS_ID",
"y": [...],
"X": [...],
"theta": [[24.0, 5.0, 81.0, 60.0, 11.0]],
"threshold": 0.50,
"is_threshold_percent": True,
"most_eval": True,
"eval_type": "both",
}
```
## Results
[[API/Prediction Engine/Results|GET /results]] returns the forecast at the threshold(s) you chose, with fit, weights, and — on the extended result — relevance, similarity, and informativeness. For categorical analysis: [[API/Prediction Engine/Binary|Binary]].
## Related
- [[API/Introduction|API]]
- [[API/Prediction Engine/Grid|Grid]] · [[API/Prediction Engine/MaxFit|MaxFit]]
- [[Functions/Predict|Predict (local)]]
<div class="btn-row center">
<a class="btn-primary" href="/API/Prediction%20Engine/Results">Retrieve results</a>
<a class="btn-ghost" href="/API/Prediction%20Engine/Binary">Binary qualifier</a>
</div>