ForHosting KIT · Developer Utilities

Least-squares regression prediction calculator

This least-squares regression prediction calculator fits a straight line to paired predictor and response data, then evaluates that fitted line at a new predictor value.

● BetaFree · in your browser
Use it from WebAPIEmailTelegramApp soon

It returns the slope, intercept, prediction, and readable equation in one deterministic result. Use it to check statistics exercises, turn a small calibration table into an estimate, or automate repeatable linear forecasts without a spreadsheet. The calculation runs entirely from the values supplied and does not use a network service, random sampling, or changing external data.

Fit the least-squares line from paired observations

Enter the observed predictor values in x and the corresponding response values in y, keeping each pair at the same array position. At least two pairs are required, both arrays must have equal length, and the x values must contain some variation. The calculator first computes the mean of each series. It then measures how x varies around its mean and how the centered x and y values vary together. Dividing the centered cross-product sum by the centered square sum for x gives the fitted slope. Subtracting the slope times mean x from mean y gives the intercept. These are the ordinary least-squares coefficients for the line written as y equals slope times x plus intercept. This line minimizes the sum of squared vertical differences between the observed responses and their fitted values. Every supplied value must be a finite number, so missing entries, numeric strings, infinities, and malformed arrays are rejected instead of being silently ignored or coerced into a misleading model. The calculation accepts up to ten thousand observation pairs per request.

Predict the response at a new input value

Supply the new predictor value in predict_x. After fitting the coefficients from the observed pairs, the calculator substitutes this new value into the same equation and returns the result as prediction. The output also includes n, slope, intercept, predict_x, the printable equation, and the ordinary_least_squares method label, making it straightforward to record both the estimate and the model that produced it. A prediction inside the observed x range is interpolation and is usually easier to defend because nearby data support the line. A prediction outside that range is extrapolation. The arithmetic is still valid, but the relationship may bend, level off, or change beyond the measurements, so interpret an extrapolated value carefully. The result is a fitted response, not a guarantee about a future observation, and this focused calculator does not produce confidence or prediction intervals. Identical input always produces identical output because the implementation uses a closed-form calculation with no network calls, randomness, timestamps, or learned model. Successful API requests use the published base price of $0.002 per item.

Check assumptions and interpret the coefficients

The slope describes the fitted change in y for a one-unit increase in x. A positive slope indicates an increasing fitted relationship, while a negative slope indicates a decreasing one. The intercept is the fitted y value when x equals zero, although it may have little practical meaning when zero is far outside the observed range. Before relying on the prediction, plot the points when possible and look for curvature, unusual observations, separated clusters, or changing vertical spread. A straight-line summary can hide all of those patterns. Also consider whether observations are meaningfully independent and whether x is measured accurately enough for ordinary least squares to suit the task. The calculator deliberately rejects a dataset whose x values are all identical because its slope denominator is zero and no unique finite least-squares slope exists. It also rejects unequal array lengths rather than guessing which observations belong together. Use the returned equation as a transparent computational summary, retain the original units when explaining slope and prediction, and avoid presenting extra decimal places as evidence of greater real-world certainty than the measurements support.

Estimate from a calibration line

Fit instrument readings against known reference values and predict the response for a new reading using the same slope and intercept.

Check a statistics exercise

Verify the least-squares coefficients and the predicted response at the input specified in a textbook or assignment.

Automate a simple linear forecast

Turn a short paired series into a repeatable fitted estimate without manually rebuilding spreadsheet formulas.

What line does the calculator fit?

It fits the ordinary least-squares line y = slope * x + intercept, minimizing squared vertical residuals for the supplied pairs.

Can I predict outside the observed x range?

Yes, but that is extrapolation. The returned arithmetic is deterministic, while the real relationship may not remain linear beyond the data.

Why are identical x values rejected?

They give zero variation in x, so the slope denominator is zero and no unique finite least-squares line of this form exists.

Does the result include a prediction interval?

No. It returns the point prediction from the fitted line, not uncertainty intervals or inferential statistics.

What does an API request cost?

A successful API request uses the published base price of $0.002 per item. Validation failures do not produce a calculation.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/calculus/linear-regression-predict

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/calculus/linear-regression-predict \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"x":[1,2,3,4],"y":[3,5,7,9],"predict_x":5}'
{
  "x": [
    1,
    2,
    3,
    4
  ],
  "y": [
    3,
    5,
    7,
    9
  ],
  "predict_x": 5
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "calculus.linear_regression_predict",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_items10000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

Read the full KIT documentation →