offline_safe_policy
Estimate the value of a target policy from logged data while respecting a per-step cost limit; uses pessimistic corrections when behavior-policy coverage is poor.
Instructions
Safe offline policy learning with a cost-constraint. Assumptions: Sequential ignorability: no unobserved confounders of actions and outcomes; Positivity: the behaviour policy explores all evaluated actions; The environment satisfies the assumed (Markov) dynamics. Pre-conditions: Logged trajectories (states, actions, rewards) from a known or estimable behaviour policy. Failure modes: Poor behaviour-policy coverage -- the target policy queries unseen state-action regions -> Use offline-safe / pessimistic methods and report effective sample size of the importance weights. Alternatives: sp.offline_safe_policy, sp.policy_value. Typical minimum N: 1000.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cost | Yes | Column names. state and action must be discrete. | |
| seed | No | Random seed for reproducible stochastic steps. | |
| state | Yes | Column names. state and action must be discrete. | |
| action | Yes | Column names. state and action must be discrete. | |
| detail | No | Payload depth: 'minimal' (~150 tokens) for sub-step calls where only the point estimate is needed; 'standard' (~1K tokens) for diagnostics + coefficient table; 'agent' (~2K tokens, default) adds violations / next_steps / suggested_functions so the LLM can plan its next call without another round-trip. | agent |
| n_iter | No | Number of iter. | |
| reward | Yes | Column names. state and action must be discrete. | |
| discount | No | discount parameter (float). | |
| as_handle | No | If true, cache the fitted result on the server and return result_id + result_uri alongside the JSON payload so a subsequent tools/call can chain without re-running. | |
| data_path | Yes | Absolute path or URL to a data file. Supported: .csv / .tsv / .txt (delimited), .parquet / .pq, .feather / .arrow, .xlsx / .xls, .dta (Stata), .json / .jsonl. Schemes: file://, s3://, gs://, https://. | |
| result_id | No | Optional handle to a previously-fitted result (returned by an earlier call when as_handle=true). Tools that operate on a fitted object accept this in place of re-supplying data_path + columns. | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. | |
| cost_threshold | No | Max allowed expected cost per step. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||