{
  "slug": "least-squares-regression",
  "name": "gizza-ai/least-squares-regression",
  "version": "0.1.0",
  "title": "Least Squares Regression Calculator — Linear & Polynomial Fits — gizza.ai",
  "description": "Fit linear, quadratic, or polynomial least-squares models to pasted x,y data. Get coefficients, R², residuals, predictions, CSV, and JSON — all locally.",
  "tags": [
    "least squares regression",
    "linear regression calculator",
    "polynomial regression",
    "r squared calculator",
    "regression coefficients",
    "trendline equation",
    "curve fitting",
    "ordinary least squares"
  ],
  "category": "data",
  "urls": {
    "page": "https://gizza.ai/tools/least-squares-regression/",
    "markdown": "https://gizza.ai/tools/least-squares-regression/index.md",
    "descriptor": "https://gizza.ai/tools/least-squares-regression/tool.json",
    "deep_link_example": "https://gizza.ai/tools/least-squares-regression/?data=x%2Cy%0A1%2C2%0A2%2C4%0A3%2C5%0A4%2C4%0A5%2C5&y_values=2%2C%204%2C%205%2C%204%2C%205&degree=1&header=auto&intercept=true&predict_x=6%2C%207&decimals=4&format=text"
  },
  "cli": "gizza tool least-squares-regression \"x,y\n1,2\n2,4\n3,5\n4,4\n5,5\"",
  "tool": {
    "description": "Fit a one-variable ordinary least-squares model to pasted x,y points. Supports linear and polynomial fits (degree 1-10), optional separate x and y lists, automatic or forced header labels, optional through-the-origin fitting, predictions at new x values, and text/csv/json output. Reports the fitted equation, coefficients with standard errors, R², adjusted R², Pearson r for straight-line fits, RMSE, residual standard error, residual spread, per-point fitted values/residuals, and predictions. Uses a deterministic Householder QR solver with column scaling rather than normal equations, so it remains stable in WASM and returns explicit rank/degree errors instead of misleading coefficients.",
    "parameters": {
      "additionalProperties": false,
      "properties": {
        "data": {
          "description": "Regression data. Paste either two columns as one x,y pair per line (CSV, semicolon, or whitespace separated), or paste only x values here and put y values in the y_values field. A first non-numeric row is treated as x/y labels when header=auto. Maximum 20,000 points.",
          "type": "string"
        },
        "decimals": {
          "default": 4,
          "description": "Decimal places for coefficients and statistics, 0 to 12. Default 4.",
          "maximum": 12,
          "minimum": 0,
          "type": "integer"
        },
        "degree": {
          "default": 1,
          "description": "Polynomial degree to fit, 1 to 10. degree=1 is ordinary straight-line least squares; degree=2 fits a quadratic; higher degrees use the same QR solver but need more distinct x values.",
          "maximum": 10,
          "minimum": 1,
          "type": "integer"
        },
        "format": {
          "default": "text",
          "description": "Output format: text summary (equation, model metrics, coefficients, residual spread, predictions), csv tables, or structured json. Default text.",
          "enum": [
            "text",
            "csv",
            "json"
          ],
          "type": "string"
        },
        "header": {
          "default": "auto",
          "description": "How to treat a leading label row/token. auto (default) consumes the first row/list item only if it is non-numeric; yes always consumes it as labels; no parses every row as data.",
          "enum": [
            "auto",
            "yes",
            "no"
          ],
          "type": "string"
        },
        "intercept": {
          "default": true,
          "description": "Fit an intercept/constant term (default true). Turn this off only when the model must pass through the origin; the reported R² then uses the uncentered total sum of squares.",
          "type": "boolean"
        },
        "predict_x": {
          "default": "",
          "description": "Optional x values to evaluate with the fitted model, separated by commas, semicolons, spaces, or newlines. Predictions are included in text, CSV, and JSON output.",
          "type": "string"
        },
        "y_values": {
          "default": "",
          "description": "Optional separate y-value list. Leave empty when data already has two columns. When set, data is parsed as the x-value list and this field as the y-value list; both lists must have the same length.",
          "type": "string"
        }
      },
      "required": [
        "data"
      ],
      "type": "object"
    }
  }
}