PeaBox Lab › PeaLang › Learn › Chapter 35 › Lesson 2

Part V — The Modern Experience Layer · Chapter 35 · Lesson 2 of 2

AutoML random search and ONNX export

Finding a good model configuration by hand is indistinguishable from superstition wearing a hoodie. v2.3.0 gives you a real — if deliberately simple — search primitive inside the language.

Random search for model selection

let result = analysis.random_search(
  "random_forest",
  X,
  y,
  "classification",
  {
    "n_trees": [50, 100, 200, 400],
    "max_depth": [3, 5, 8, null],
    "min_samples_split": [2, 5, 10]
  },
  { "n_iter": 20, "seed": 42 }
)

print result.n_candidates   # 20
print result.task           # "classification"
print result.best_model     # the winning estimator

The PeaLang-facing API is positional: random_search(model_type, X, y, task, param_space, n_iter=10, seed=42), returning {"n_candidates", "task", "best_model"}. The seed makes runs reproducible — same seed, same candidates, same winner. n_iter bounds the budget. Random search consistently beats grid search when only a few hyperparameters matter, which is most real problems; grid search wastes its budget enumerating the irrelevant dimensions at full cost.

Where this fits with Chapter 19

ONNX export

let onnx = analysis.export_to_onnx(model, { "input": "x", "output": "y" })

export_to_onnx emits an ONNX-shaped export stub — an interchange boundary for moving fitted models out of PeaLang into runtimes you do not own (Python onnxruntime, browser JS runtimes, mobile). Current status: a deliberate stub. Treat it as the contract point, and verify round-trip predictions before trusting the export for anything user-facing. When it matures, the interface is designed to stay — the stub grows a backend, not a new API.

A realistic AutoML workflow

# 1. Split honestly: train / validation / frozen holdout (Chapter 19).
# 2. Search within each candidate family on the validation set.
# 3. Pick the winning family by validation score.
# 4. Retrain the winner on train+validation with the winning config.
# 5. Report exactly once on the frozen holdout.
# 6. Register through the Chapter 20 lifecycle — bundle, sign, promote.

Failure modes worth knowing

Guided practice

← Previous Next →