# Regression model trainer

Fit linear, ridge, or bounded random-forest regression from a pasted numeric table and report R², RMSE, MAE, coefficients, or feature importance.

## Run it

- **CLI:** `gizza tool regression-model-trainer "x,y
1,3
2,5
3,7
4,9"`
- **Web:** https://gizza.ai/tools/regression-model-trainer/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/regression-model-trainer/tool.json

## Inputs

- `data` — Training table _(field)_
- `target` — Target column _(field)_
- `features` — Feature columns _(field)_
- `model` — Model _(field)_
- `alpha` — Ridge alpha _(field)_
- `standardize` — Standardize predictors for ridge _(field)_
- `trees` — Forest trees _(field)_
- `max_depth` — Forest max depth _(field)_
- `test_split` — Test split _(field)_
- `cv_folds` — CV folds _(field)_
- `seed` — Seed _(field)_
- `header` — Header row _(field)_
- `decimals` — Decimal places _(field)_
- `format` — Output format _(field)_

## Output

- Model report (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `data` — Training table
- `target` — Target column
- `features` — Feature columns
- `model` — Model
- `alpha` — Ridge alpha
- `standardize` — Standardize predictors for ridge
- `trees` — Forest trees
- `max_depth` — Forest max depth
- `test_split` — Test split
- `cv_folds` — CV folds
- `seed` — Seed
- `header` — Header row
- `decimals` — Decimal places
- `format` — Output format

Example: `https://gizza.ai/tools/regression-model-trainer/?data=x%2Cy%0A1%2C3%0A2%2C5%0A3%2C7%0A4%2C9&target=last&features=x1%2Cx2&model=linear&alpha=1&standardize=true&trees=100&max_depth=8&test_split=0&cv_folds=0&seed=42&header=auto&decimals=4&format=text`

---

## About this tool

Train a regression model from a pasted numeric table without uploading data. The tool parses CSV,
TSV, semicolon, pipe, or whitespace-delimited rows, picks a target column, and fits ordinary least
squares, ridge regression, or a bounded deterministic random forest. Reports include R², RMSE, MAE,
row counts, optional hold-out and cross-validation metrics, plus coefficients for linear/ridge or
feature-importance shares for random forest.

Worked example:

```csv
x,y
1,3
2,5
3,7
4,9
```

With target `y` and model `linear`, the fitted equation is `y = 1 + 2·x`, with R² of 1 and RMSE 0.
For multiple predictors, set `features` to a comma-separated list such as `sqft,rooms`, or leave it
blank to use every non-target numeric column.

Limits and edge cases: the table is capped at 20,000 rows and 100 columns. All selected predictors
and the target must be numeric; encode categories as numeric dummy columns before using this tool.
Random forest work is capped, so reduce rows, trees, or CV folds for larger tables. Coefficients are
not causal claims; they summarize the pasted data under the chosen model.

## FAQ

<details>
<summary>Which model should I choose?</summary>

Use `linear` for a quick ordinary least squares equation, `ridge` when predictors are correlated or
have different scales, and `random_forest` when the relationship is nonlinear and you care more about
prediction and importance than a simple equation.

</details>

<details>
<summary>How do I select columns?</summary>

`target` accepts `last`, `first`, a 1-based index, or a header name. `features` is optional; leave it
blank to use every other column, or list columns such as `sqft,rooms` or `1,3` to fit only those
predictors.

</details>

<details>
<summary>What happens to missing or non-numeric values?</summary>

Rows with missing values such as `NA`, `null`, or blank cells in selected columns are dropped and
reported. Non-numeric text in selected predictors or the target is an error, because this tool does
not perform automatic categorical encoding.

</details>

<details>
<summary>Is the random forest reproducible?</summary>

Yes. Bootstrap samples, feature choices, train/test splits, and cross-validation folds all use the
`seed` value, so the same data and options produce the same report.

</details>

## Related tools

- [ARFF Converter](https://gizza.ai/tools/arff-converter/): Convert Weka ARFF datasets to CSV and CSV tables back to ARFF locally — nominal attributes, numeric types, dates, sparse rows, missing values, and type rows.
- [Smooth a noisy numeric series with a cubic spline](https://gizza.ai/tools/spline-smoother/): Fit a cubic smoothing spline to noisy numeric data. Choose automatic GCV/CV smoothing, p, lambda, or target degrees of freedom and return JSON, CSV, or SVG.
- [Beancount to CSV Converter](https://gizza.ai/tools/beancount-to-csv/): Flatten Beancount or Ledger journal postings into spreadsheet-ready CSV, then rebuild a simple journal from that flat CSV schema.
- [Cartesian to polar CSV converter](https://gizza.ai/tools/cartesian-to-polar-csv/): Convert a whole CSV of (x, y) points to polar (r, θ) coordinates in your browser, in degrees or radians, keeping your other columns intact.
- [CSV Cell Diff](https://gizza.ai/tools/csv-cell-diff/): Compare two CSVs column-by-column and highlight every individual cell that changed, plus added and removed rows and columns.
