> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mathfi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Input CSV File Format

> How to format your labelled CSV data for MathFi.ai. Covers column requirements, target variable setup, and data preparation tips.

This guide outlines how to correctly format CSV files so they can be used for dataset creation, training and inference within MathFi.ai predictive platform.

<br />

### File format overview

* **Accepted format**: `.csv`
* **Maximum file size**: 500 MB
* **Minimum recommended rows**: Several hundreds
* **Delimiter**: Comma (`,`)

<br />

### Input CSV creation guide

Continue reading this guidelines or watch this video for a walkthrough on how CSV data should look like:

<iframe className="w-full aspect-video rounded-xl" src="https://www.youtube.com/embed/CWD0RtWHkRU?rel=0" title="Input CSV creation walkthrough" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />

### Training CSV Format

<br />

The structure of the training file must follow this format:

* **First Row**: Name of each column of features
* **First column**: Unique ID (e.g., sample ID, row identifier)
* **Last column**: Target/label. Binary or multi-class, can be numeric (`0`, `1`) or text (`N`, `Y`, `Class1`, `Class4`,...)
* **Middle columns**: Feature data (numeric or string values)

```csv theme={null}
ID,Feature0,Feature1,Feature2,Feature3,Feature4,Feature5,Feature6,Feature7,Feature8,Target
1000025,5,A,1.767,1,Low,1,-3,1,1,N
1002945,5,A,4.367,5,Medium,10,3,2,1,P
1015425,3,B,1.98,1,Low,2,-7,1,1,N
...
```

Additional requirements for best results:

* The smallest class represented in the CSV file should have at least 25 rows (labelled samples)
* While up to 500 MB is supported, the recommendation is having no more than 250000 rows per training data CSV in for current release. Can go beyond, but processing may be significantly slower

<Note>It is highly recommended to shuffle the rows randomly to improve training performance</Note>

<br />

### Prediction CSV format

<br />

Your prediction CSV should have exactly the same format as your training data, except **without the final target column**. For example:

```csv theme={null}
ID,Feature0,Feature1,Feature2,Feature3,Feature4,Feature5,Feature6,Feature7,Feature8
3359991,10,D,1.565,2,High,6,-5,3,5
5618561,3,A,12.3,3,Low,11,-6,2,1
7199078,2,C,8.3,1,High,1,1,4,5
```

<Note>This file is referred also as **blind data**, **unseen data**</Note>

<br />

### Common pitfalls to avoid

<br />

##### Null or missing values

Do not use NULL in your CSV. Instead, leave the cell blank (i.e., ,,).

<br />

##### Filenames with spaces

Avoid filenames like:

✗ `Milk Quality.csv`

Use instead:

✓ `MilkQuality.csv`

<br />

##### Multiple columns with unique identifiers

You must only have one ID-like column. If additional columns contain unique strings (like names), MathFi.ai may treat them as identifiers and reduce prediction quality:

```csv theme={null}
ID,Feature0,...,Feature3,...,Target
1000025,5,...,"Jack Smith",...,N
```

<Note>Fix by removing or encoding the second identifier column</Note>

<br />

##### Sorting by a single feature

Do not pre-sort the data by any feature column (e.g. by `Feature2`), as this will reduce model accuracy. Random row order is essential. Example of poorly formatted file (sorted):

```csv theme={null}
ID,Feature0,Feature1,Feature2,...,Target
1017023,4,A,1.355,...,N
1035283,1,D,1.4,...,N
...
```

<Note>**Shuffle the dataset instead.**</Note>

<br />

### Summary

<br />

* First column as the unique ID
* Last column (for training only), target label (text or number). Empty for prediction CSV
* Middle columns as features (numeric or categorical)
* Max file size is 500 MB
* Minimum row count to be mid to high hundreds
* No `NULL`s, leave cells blank instead
* File names without spaces
* Avoid row ordering, shuffle them instead
* Ensure only one unique ID column per file
* No character or text in numeric columns: if a column in the input csv file is intended to be numeric, please avoid having characters or text in that columns as data features. It should be purely numeric

<Note>By following these guidelines, you ensure maximum compatibility and performance from the MathFi.ai platform</Note>
