Metadata-Version: 2.4
Name: tamarix_analytics
Version: 0.0.8
Summary: A Python package for row matching and F1 score calculations.
Author: Tamarix Technologies
Author-email: kristian@tamarix.tech
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: munkres
Requires-Dist: pydantic
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Tamarix Analytics

A Python package for row matching and F1 score calculations using the Hungarian algorithm.

## Installation

```bash
pip install tamarix-analytics
```

## Usage

```python
from tamarix_analytics import (
    match_rows,
    f1_score_unordered,
    f1_score_ordered,
    get_row_score,
    f1_score_ordered_by_field,
    f1_score_ordered_by_field_with_nested,
    extract_nested_rows,
    detect_nested_list_fields,
)
```

## Methods

### Document-level scores

- `match_rows(tentative_data, baseline_data)` — Hungarian row alignment.
- `f1_score_unordered(tentative_data, baseline_data)` — bag-of-values F1.
- `f1_score_ordered(tentative_data, baseline_data)` — structure-aware F1 after matching.
- `get_row_score(tentative_data, baseline_data)` — `len(tentative) / len(baseline)`.

### Field-level scores

- `f1_score_ordered_by_field(tentative_data, baseline_data) -> dict[str, float]` —
  per-field ordered F1. Returns `{}` when both sides have at most one row.
  Skips list-of-dict container fields. Omits fields with no evidence (both-None).
- `f1_score_ordered_by_field_with_nested(...)` — same as above, plus nested
  list-of-dict fields scored after concatenating all nested objects across main
  rows. Nested keys are namespaced (`sub_amounts.amount`, `sub_amounts.type`, …).
- `extract_nested_rows(rows, nested_field)` / `detect_nested_list_fields(rows)` —
  helpers for nested tables.

Both sides must be `list[BaseModel]` with a shared field schema (except nested
union keys, which are aligned automatically by `f1_score_ordered_by_field_with_nested`).
