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

# Tabular Data

> Train models on structured tabular data

# Tabular Data

Train models on structured data like CSVs and databases.

## Quick Start

```bash theme={null}
aitraining tabular --train \
  --model xgboost \
  --data-path ./data.csv \
  --target-columns target \
  --valid-split validation \
  --project-name tabular-model
```

<Warning>
  Tabular training requires `--valid-split` to specify a validation split in your data.
</Warning>

## Task Types

### Classification

Predict categorical labels:

```bash theme={null}
aitraining tabular --train \
  --model xgboost \
  --data-path ./customers.csv \
  --target-columns churn \
  --valid-split validation \
  --task classification \
  --project-name churn-predictor
```

### Regression

Predict continuous values:

```bash theme={null}
aitraining tabular --train \
  --model xgboost \
  --data-path ./houses.csv \
  --target-columns price \
  --valid-split validation \
  --task regression \
  --project-name price-predictor
```

## Parameters

| Parameter               | Description                     | Default          |
| ----------------------- | ------------------------------- | ---------------- |
| `--model`               | Model type                      | `xgboost`        |
| `--data-path`           | Path to CSV/data                | None (required)  |
| `--project-name`        | Output directory                | `project-name`   |
| `--target-columns`      | Target variable(s)              | `["target"]`     |
| `--task`                | classification/regression       | `classification` |
| `--train-split`         | Training data split             | `train`          |
| `--valid-split`         | Validation data split           | None (required)  |
| `--id-column`           | ID column to exclude            | `id`             |
| `--categorical-columns` | Categorical features            | `None`           |
| `--numerical-columns`   | Numerical features              | `None`           |
| `--num-trials`          | Number of hyperparameter trials | `10`             |
| `--time-limit`          | Time limit in seconds           | `600`            |
| `--seed`                | Random seed                     | `42`             |

## Available Models

| Model                 | Classification | Regression |
| --------------------- | -------------- | ---------- |
| `xgboost`             | Yes            | Yes        |
| `random_forest`       | Yes            | Yes        |
| `extra_trees`         | Yes            | Yes        |
| `gradient_boosting`   | Yes            | Yes        |
| `adaboost`            | Yes            | Yes        |
| `decision_tree`       | Yes            | Yes        |
| `logistic_regression` | Yes            | Yes        |
| `ridge`               | Yes            | Yes        |
| `svm`                 | Yes            | Yes        |
| `knn`                 | Yes            | Yes        |
| `naive_bayes`         | Yes            | No         |
| `lasso`               | No             | Yes        |
| `linear_regression`   | No             | Yes        |

## Data Format

### CSV Format

```csv theme={null}
feature1,feature2,feature3,target
1.5,category_a,100,1
2.3,category_b,200,0
```

### Handling Features

Specify categorical columns:

```bash theme={null}
aitraining tabular --train \
  --model gradient_boosting \
  --data-path ./data.csv \
  --target-columns target \
  --valid-split validation \
  --categorical-columns "color,size,region" \
  --project-name model
```

Exclude ID columns:

```bash theme={null}
aitraining tabular --train \
  --model xgboost \
  --data-path ./data.csv \
  --target-columns target \
  --valid-split validation \
  --id-column customer_id \
  --project-name model
```

## Examples

### Customer Churn

```bash theme={null}
aitraining tabular --train \
  --model xgboost \
  --data-path ./customers.csv \
  --target-columns churned \
  --valid-split validation \
  --id-column customer_id \
  --task classification \
  --project-name churn-model
```

### House Price Prediction

```bash theme={null}
aitraining tabular --train \
  --model gradient_boosting \
  --data-path ./houses.csv \
  --target-columns sale_price \
  --valid-split validation \
  --id-column house_id \
  --task regression \
  --project-name house-prices
```

### Multi-Class Classification

```bash theme={null}
aitraining tabular --train \
  --model extra_trees \
  --data-path ./products.csv \
  --target-columns category \
  --valid-split validation \
  --categorical-columns "brand,color,material" \
  --task classification \
  --project-name product-classifier
```

## Model Comparison

For comparing different models on your data:

```bash theme={null}
# Train XGBoost
aitraining tabular --train \
  --model xgboost \
  --data-path ./data.csv \
  --target-columns target \
  --valid-split validation \
  --project-name model-xgb

# Train Random Forest
aitraining tabular --train \
  --model random_forest \
  --data-path ./data.csv \
  --target-columns target \
  --valid-split validation \
  --project-name model-rf

# Train Gradient Boosting
aitraining tabular --train \
  --model gradient_boosting \
  --data-path ./data.csv \
  --target-columns target \
  --valid-split validation \
  --project-name model-gb
```

## Output

After training, you'll find:

```
project-name/
├── model.joblib        # Trained model
├── metrics.json        # Evaluation metrics
├── feature_importance.json
└── config.yaml         # Training config
```

## Loading Models

```python theme={null}
import joblib

model = joblib.load("project-name/model.joblib")
predictions = model.predict(new_data)
```

## Next Steps

<CardGroup cols={2}>
  <Card title="Text Tasks" href="/cli/text-tasks">
    Text classification
  </Card>

  <Card title="Vision Tasks" href="/cli/vision-tasks">
    Image classification
  </Card>
</CardGroup>
