pysr_uncertainty
Bootstrap confidence intervals for the numeric constants of a frozen expression, plus optional prediction bands on an x-grid.
Typical flow: call pysr_run, pick an expression from the response
(best_expression or a pareto_front entry), pass it back here with
the same dataset to get CIs on its fit constants.
Returns frequentist bootstrap confidence intervals, not Bayesian
credible intervals — posterior inference over expression structures
is an open research problem. This tool freezes the expression
chosen by the caller and bootstraps only its numeric constants;
uncertainty about *which* expression is correct is not quantified.
Bootstrap semantics:
- If y_sigma is supplied, uses parametric bootstrap
(y_b = y + Normal(0, y_sigma)). CI reflects user-stated
measurement noise.
- Otherwise uses residual bootstrap: fit once, resample residuals.
CI reflects estimated-from-residuals noise.
Only Float constants in the expression become free parameters.
Integers stay structural (the 2 in x**2 is a function-class choice,
not a fit constant). Expressions with no Float constants
(e.g. "x + y") will be rejected with a validation error.
Expression grammar: the `expression` string is parsed by sympy.
Accepted operators are the same set pysr_run emits: unary `sin`,
`cos`, `tan`, `exp`, `log`, `log2`, `log10`, `sqrt`, `abs`, `sinh`,
`cosh`, `tanh`; binary `+`, `-`, `*`, `/`, `^` (or `**`). Whitespace
and parenthesization are free. Every free symbol in the expression
must correspond to an entry in `feature_names` — an unrecognised
symbol is silently treated as a fresh sympy Symbol and the fit will
fail downstream rather than reject early. Parse failures (syntax
errors, malformed operators) surface as tool errors.
If `feature_names` is supplied, its length must equal the number of
columns in `X`; a mismatch is rejected with a validation error.
Pricing: always free, regardless of dataset size. This tool has no
`payment` parameter and is never subject to the x402/Stripe gate.
Large bootstrap jobs still count against the shared rate limit
below, so budget `n_resamples` accordingly.
Rate limit: 10 requests/hour per IP, 200/hour global, max queue
depth 20 (shared with sindy_run and pysr_run).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"expression": "<expression>",
"X": "<X>",
"y": "<y>"
},
"name": "pysr_uncertainty"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| X | Yes | 2D array of input features. Each row is an observation, each column is a feature. Minimum 5 rows. Free tier: 100 rows, 8 features. Paid tier: up to 50,000 rows, 20 features. | |
| y | Yes | Target values, one per row of X. | |
| alpha | No | Significance level. 0.05 → 95%% CI. Default 0.05. | |
| x_grid | No | Optional 2D grid of feature values at which to report a prediction band. Must have the same number of columns as X. Omit to skip prediction-band computation. | |
| y_sigma | No | Optional per-point measurement standard deviations, or a single scalar applied to all points. When supplied, the helper uses parametric bootstrap (y_b = y + Normal(0, y_sigma)); otherwise it uses residual bootstrap. Supplying y_sigma also improves the initial weighted fit. | |
| expression | Yes | The expression to bootstrap, as returned by pysr_run (`best_expression` or a `pareto_front[i].expression`). Only numeric Float constants are treated as free parameters — integers in the expression (e.g. the 2 in x**2) stay structural. | |
| n_resamples | No | Number of bootstrap resamples. Higher = tighter CIs, more compute. Default 100. | |
| feature_names | No | Names for each variable/feature column. Defaults to x0, x1, ... |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note | Yes | ||
| alpha | Yes | ||
| coefficients | Yes | ||
| prediction_ci | No | ||
| bootstrap_method | Yes | ||
| n_requested_resamples | Yes | ||
| n_successful_resamples | Yes |