# 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.

## Run it

- **CLI:** `gizza tool arff-converter "@relation weather
@attribute outlook {sunny,overcast,rainy}
@attribute temperature numeric
@data
sunny,85
rainy,70"`
- **Web:** https://gizza.ai/tools/arff-converter/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/arff-converter/tool.json

## Inputs

- `data` — ARFF or CSV input _(field)_
- `direction` — Direction _(field)_
- `delimiter` — CSV delimiter _(field)_
- `header` — CSV has/writes header row _(field)_
- `relation` — ARFF relation name _(field)_
- `nominal_threshold` — Nominal threshold _(field)_
- `column_types` — Forced column types _(field)_
- `date_format` — Date format _(field)_
- `missing_value` — CSV missing-value token _(field)_
- `arff_format` — ARFF row format _(field)_
- `type_row` — Include/consume CSV type row _(field)_

## Output

- Converted dataset (text)

## Query parameters

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

- `data` — ARFF or CSV input
- `direction` — Direction
- `delimiter` — CSV delimiter
- `header` — CSV has/writes header row
- `relation` — ARFF relation name
- `nominal_threshold` — Nominal threshold
- `column_types` — Forced column types
- `date_format` — Date format
- `missing_value` — CSV missing-value token
- `arff_format` — ARFF row format
- `type_row` — Include/consume CSV type row

Example: `https://gizza.ai/tools/arff-converter/?data=%40relation%20weather%0A%40attribute%20outlook%20%7Bsunny%2Covercast%2Crainy%7D%0A%40attribute%20temperature%20numeric%0A%40data%0Asunny%2C85%0Arainy%2C70&direction=auto&delimiter=%2C&header=true&relation=weather&nominal_threshold=10&column_types=class%3Anominal%2C2%3Anumeric%2Cdate%3Adate&date_format=yyyy-MM-dd%27T%27HH%3Amm%3Ass&missing_value=NA&arff_format=dense&type_row=true`

---

## Convert ARFF and CSV datasets locally

Weka's ARFF format stores a relation name, typed attributes and a data section.
This converter turns ARFF into CSV for spreadsheets and notebooks, or turns CSV
back into ARFF for Weka-style machine-learning workflows. Everything runs in the
browser with the same pure-Rust core used by the CLI and chat tool.

### Worked examples

ARFF to CSV:

```arff
@relation weather
@attribute outlook {sunny,overcast,rainy}
@attribute temperature numeric
@data
sunny,85
rainy,70
```

With direction **ARFF → CSV**, the output is:

```csv
outlook,temperature
sunny,85
rainy,70
```

CSV to ARFF:

```csv
outlook,temperature
sunny,85
rainy,70
```

With relation `weather`, the converter infers `temperature` as `numeric` and
`outlook` as a nominal label set because it has only a few distinct values.

### Preserving attribute types

CSV has no native place to store ARFF attribute types. Enable **Include/consume
CSV type row** when converting ARFF to CSV to add a second row containing each
attribute type. Convert that CSV back with the same option enabled and the ARFF
header keeps numeric, string, date and nominal declarations instead of guessing.
You can also force types with `column_types`, for example
`class:nominal,id:string,3:date`.

### Supported ARFF details

The converter handles `%` comments, quoted names and values, escaped newlines and
tabs, nominal `{a,b,c}` label sets, date attributes with a format pattern,
missing values as `?`, dense rows, sparse `{index value, ...}` rows and trailing
instance weights. Relational multi-instance attributes are intentionally rejected
with a clear error because flattening them is schema-specific.

## FAQ

<details>
<summary>How are CSV column types inferred?</summary>

All-numeric columns become `numeric`. Non-numeric columns with at most the
nominal threshold of distinct values become nominal attributes such as
`{yes,no}`. Larger text columns become `string`. You can override any column by
name or 1-based index with `column_types`.

</details>

<details>
<summary>How do I keep ARFF types during a round trip?</summary>

Turn on **Include/consume CSV type row** when converting ARFF to CSV. The CSV
then has a second row with type declarations. When converting back to ARFF with
the same option, those declarations are used instead of guessing from data.

</details>

<details>
<summary>Can it read sparse ARFF rows?</summary>

Yes. Sparse rows are expanded to dense CSV cells using type-aware defaults: zero
for numeric attributes, the first label for nominal attributes, and empty text
for string/date attributes. When writing ARFF you can choose dense or sparse row
output.

</details>

<details>
<summary>What happens to missing values?</summary>

ARFF `?` values become empty CSV cells by default. Set a missing-value token such
as `NA` if your CSV workflow needs an explicit marker; the same token is read
back as `?` when converting CSV to ARFF.

</details>

## Related tools

- [Regression model trainer](https://gizza.ai/tools/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.
- [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.
- [CSV timeline viewer](https://gizza.ai/tools/csv-timeline-viewer/): Paste a CSV, TSV or JSON Lines event log and filter it by time range, search every column, sort, pick columns and page through the matches locally.
