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

# Dados Tabulares

> Treine modelos em dados tabulares estruturados

# Dados Tabulares

Treine modelos em dados estruturados como CSVs e bancos de dados.

## Início Rápido

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

<Warning>
  O treinamento tabular requer `--valid-split` para especificar uma divisão de validação nos seus dados.
</Warning>

## Tipos de Tarefas

### Classificação

Prever rótulos categóricos:

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

### Regressão

Prever valores contínuos:

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

## Parâmetros

| 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`             |

## Modelos Disponíveis

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

## Formato dos Dados

### Formato CSV

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

### Tratamento de Features

Especifique colunas categóricas:

```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
```

Excluir colunas de ID:

```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
```

## Exemplos

### Churn de Clientes

```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
```

### Predição de Preço de Casa

```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
```

### Classificação Multi-Classe

```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
```

## Comparação de Modelos

Para comparar diferentes modelos nos seus dados:

```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
```

## Saída

Após o treinamento, você encontrará:

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

## Carregando Modelos

```python theme={null}
import joblib

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

## Próximos Passos

<CardGroup cols={2}>
  <Card title="Tarefas de Texto" href="/cli/text-tasks">
    Classificação de texto
  </Card>

  <Card title="Tarefas de Visão" href="/cli/vision-tasks">
    Classificação de imagem
  </Card>
</CardGroup>
