---
layout: default
title: Configuration
nav_order: 6
---

# Configuration

infermap works with zero configuration. For fine-tuning, use YAML config files.

## infermap.yaml

Override scorer weights, disable scorers, and extend the alias registry:

```yaml
# infermap.yaml
scorers:
  FuzzyNameScorer:
    weight: 0.2          # downweight fuzzy matching
  PatternTypeScorer:
    weight: 0.9          # boost type detection
  LLMScorer:
    enabled: false        # disable a scorer entirely

aliases:
  mrn: [medical_record_number, patient_id, chart_number]
  npi: [provider_id, national_provider_identifier]
```

Pass to the engine:

```python
engine = infermap.MapEngine(config_path="infermap.yaml")
result = engine.map(source, target)
```

## Saved Mapping Configs

After running a mapping, save the results for reproducible reuse:

```python
result = infermap.map("source.csv", "target.csv")
result.to_config("mapping.yaml")
```

This creates:

```yaml
# Generated by infermap
version: "1"
mappings:
  - source: fname
    target: first_name
    confidence: 0.95
  - source: email_addr
    target: email
    confidence: 0.97
unmapped_source:
  - internal_ref
unmapped_target: []
```

Reload and apply without re-running inference:

```python
result = infermap.from_config("mapping.yaml")
remapped = result.apply(new_data_df)
```

## Schema Definition Files

Declare target field metadata explicitly:

```yaml
# target_schema.yaml
fields:
  - name: email
    type: string
    aliases: [email_address, e_mail, contact_email]
    required: true
  - name: phone
    type: string
    aliases: [telephone, tel, mobile]
    required: false
  - name: zip_code
    type: string
    aliases: [postal, postcode, zip]
```

Use as an overlay:

```python
result = infermap.map("source.csv", "target.csv", schema_file="target_schema.yaml")
```

Or via CLI:

```bash
infermap map source.csv target.csv --schema-file target_schema.yaml
```

## Required Fields

Specify fields that must be mapped. Unmapped required fields generate warnings.

Three sources of required fields (unioned together):
1. `required=["email", "phone"]` parameter on `map()`
2. `--required email,phone` CLI flag
3. `required: true` in schema definition files

With `--strict`, the CLI exits code 1 if any required field is unmapped:

```bash
infermap validate source.csv --config mapping.yaml --required email --strict
```

## Engine Parameters

| Parameter | Default | Description |
|-----------|---------|-------------|
| `min_confidence` | 0.3 | Minimum combined score to keep a mapping |
| `sample_size` | 500 | Number of rows to sample for profiling |
| `scorers` | `default_scorers()` | List of scorer instances |
| `config_path` | None | Path to infermap.yaml for overrides |
