# ModelFitApp

Source: https://obsvra.com/docs/modelfitapp

> ModelFitApp — a first-pass model for a real data sample, without an agent

> © 2026 Obsvra. This document describes SpiceGrinder and is provided to help you evaluate and use it. It is not a license to reproduce, adapt, or use this material to build a competing product or service. Full terms: the SpiceGrinder EULA.

## NAME

ModelFitApp — a first-pass model for a real data sample, without an agent

## SYNOPSIS

```
java -cp spicegrinder.jar com.obsvra.spicegrinder.tools.ModelFitApp [options] sample.csv
```

On a jpackage install:

```
fit [options] sample.csv
```

## DESCRIPTION

`fit` reads a sample with a header row and writes three things:

- **A profile** (`<model>.profile.json`): every column's kind, statistics and percentiles, the candidate distributions it tried with their BIC and Kolmogorov-Smirnov distance, the exact values it found frequent, the body-and-tail splice it tried, rank correlations, rows per identifier, rules that hold in every row, and a list of what it left **undecided**.
- **A draft model** (`<sample>-fit.xml` unless `-o` names it), one output column per sample column, in order.
- **A comparison** of the draft with the sample, as [`compare`](https://obsvra.com/docs/modelcompareapp) prints it.

It is a starting point, not a finished model. It applies the mechanical rules of the `fit-model-to-sample` agent skill with the skill's own thresholds, and gives the same numbers every time. The judgment calls stay with you or the agent: whether a column identifies someone, which business object a format matches, whether a split means something, when a poor fit is good enough. Read the undecided list first.

## WHAT IT DOES WITH EACH COLUMN

| Column | Draft |
|---|---|
| Numbers | The candidate with the lowest BIC among `Normal`, `Lognormal`, `Gamma`, `Weibull`, `Exponential` and `Uniform`, fitted by maximum likelihood. A `Normal` over a column with no negative values is truncated at 0. Rounded to the sample's decimal places, or to whole numbers |
| Exact values seen in 1% of rows and at least 10 times (spikes) | Replayed in an `Empirical`, mixed with the fit of the remaining rows, when the column looks like a plain measurement. When values seen in 0.2% of rows and 10 times cover at least half the rows (a price list, pack sizes), all of those are replayed |
| A long right tail | When the single fit misses the 99th percentile by more than 10% and there are 100 rows above the 95th percentile: a body below it (`Truncate` of the best of `Lognormal`, `Gamma`, `Weibull`) and a `Pareto` above it, kept only when it is closer at the 99th percentile and its KS is no worse |
| Correlated numbers | Pairs with a rank correlation of at least 0.1 and three standard errors join one `Copula`, with `r = 2 sin(pi rs / 6)`, shrunk toward 0 if the matrix is not positive definite |
| A category (up to 50 values, those seen 10 times covering 95% of rows) | `Categorical` of its shares, written as codes 0, 1, 2 (a Free model has no text categories; the codes are listed in the model's comment). On Pro, a weighted `FlatFile` over a small table of the labels written beside the model. Values seen fewer than 10 times are left out |
| Identifiers, dates, free text | A `Sequence` placeholder, listed as undecided, with the business object its shape suggests (`SSN`, `Phone`, `Email`, ...) |

**Never replayed:** a column whose name has a word that suggests an identifier, a date or an attribute of a person (`id`, `zip`, `phone`, `account`, `member`, `name`, `date`, `age`, ...), a whole-number column whose values are nearly all different, dates, and any value seen fewer than 10 times. Those columns are fitted, not copied.

**Not built yet, listed as undecided:** entities (rows that repeat per identifier; the profile gives rows per entity in ranges, the columns fixed per entity and whether 10 entities stand behind them, but the draft does not build the `Pool`), rules that hold in every row (`a <= b`), blank values, mixtures and splits by a category.

## OPTIONS

`-o`, `--out FILE`
: The draft model. Default: `<sample>-fit.xml` in the working directory.

`--profile FILE`
: The profile. Default: beside the model, with `.profile.json` in place of its extension.

`--delimiter C`
: The sample's field separator (default `,`; `tab` for a tab).

`--seed N`
: The seed of the comparison (default 1).

`--no-check`
: Write the model and profile without comparing.

## EXIT STATUS

0 when the comparison found nothing high-severity, 1 when it did (the draft is written either way), 2 for bad arguments or a sample that cannot be read.

## SEE ALSO

[ModelCompareApp](https://obsvra.com/docs/modelcompareapp), [Reviewing a Fitted Model](https://obsvra.com/docs/reviewing-a-fitted-model), the `fit-model-to-sample` skill.
