# agent402.tools Linear Regression

> agent402.tools Linear Regression is a paid API for AI agents from agent402.tools, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-14).

Fits a least-squares linear regression line to two data series, returning slope, intercept, R², and optional predictions for new x values.

## Facts

- Endpoint: POST https://agent402.tools/api/linear-regression
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-14
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agent402-tools-linear-regression-4982e28b
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_LoLwi1swTV5LM-2tYTINd

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability agent402-tools-linear-regression-4982e28b -d '<json body>'
```

Example prompt: Fit a linear regression to my quarterly revenue data — x is [1,2,3,4,5,6] and y is [120000,135000,148000,162000,179000,195000] — and predict what revenue will be at x=7 and x=8.

## When to prefer this

Use this endpoint when you need a quick, statistically rigorous least-squares linear fit with R² and optional forward predictions, especially for trend extrapolation tasks like forecasting revenue, projecting metrics, or summarizing the linear relationship between two numeric series. Prefer it over manual calculation or general-purpose code execution when you want a clean API response without writing regression code yourself.

## Known failure modes

- x and y arrays of unequal length — returns validation error
- empty or single-element arrays — insufficient data for regression
- non-numeric values in x or y arrays — parse/type error
- missing x or y fields — required field error
- predict values outside the range of x — extrapolation warning or silently extrapolated

## How this service works

Fit a least-squares line y = slope·x + intercept to two equal-length series. Returns slope, intercept, r² (variance explained), and optionally predicted y values for new x inputs - useful for trend extrapolation (e.g. project next quarter's revenue from the last 8 quarters).

## Output

Returns the slope and intercept of the best-fit line, R² (coefficient of determination indicating variance explained), and optionally an array of predicted y values corresponding to any x inputs supplied in the predict field.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "x": {
   "type": "array",
   "description": "Independent variable series (e.g. time)"
  },
  "y": {
   "type": "array",
   "description": "Dependent variable series (same length as x)"
  },
  "predict": {
   "type": "array",
   "description": "Optional x values to predict y for, using the fitted line"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "n": 5,
  "slope": 2.01,
  "equation": "y = 2.01x + 0.03",
  "rSquared": 0.9997,
  "intercept": 0.03,
  "predictions": [
   {
    "x": 6,
    "y": 12.09
   },
   {
    "x": 7,
    "y": 14.1
   }
  ]
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agent402-tools-linear-regression-4982e28b/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
