{"uid":"cap_LoLwi1swTV5LM-2tYTINd","slug":"agent402-tools-linear-regression-4982e28b","name":"agent402.tools Linear Regression","description":"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).","url":"https://agent402.tools/api/linear-regression","method":"POST","headers":{},"bodySchema":{"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"}}},"responseSchema":{"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}]}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_NaLByj1TCOePeJqo4R4fP","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Fits a least-squares linear regression line to two data series, returning slope, intercept, R², and optional predictions for new x values.","exampleAgentPrompt":"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.","exampleUseCases":null,"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T19:14:07.212Z","isFirstParty":false}