ml.gradient_boosting

Histogram gradient boosting regression or classification (scikit-learn). Writes a SpadeModel with an ONNX graph that models.predict scores without Python; before the model is written, the graph scores the training rows and must agree with the fitted model, or the block fails. Early stopping is off, so the number of trees never depends on a random validation split.

  • Kind: standard
  • Network: no

Inputs🔗

NameTypeDescription
datafile (Parquet or CSV)Training table: one row per observation, with the target, the predictor columns, and any weights or id columns.
targetstringThe response column.
featuresstringColumn selector for the predictors: names, globs and exclusions, e.g. B*,MB*,-B0.
taskstringregression (default) predicts a number; classification predicts the target's classes, with a probability for each.
id_columnsstringColumn selector for identifier columns, never used as predictors; kept as text when reading CSV. Default empty.
weightsstringColumn of non-negative observation weights. Empty fits unweighted.
categoricalstringColumn selector for numeric-coded predictors to treat as categorical. Categoricals are one-hot encoded, one column per level. Default empty.
na_actionstringfail (default, naming the columns) or drop: what to do with a row that has a missing value in a model column.
seednumberSeed for the model's randomness and for fold assignment; the same seed gives the same model. Default 0.
cv_foldsnumberK-fold cross-validation (0 for none). The model is always fitted on all rows. Default 0.
cv_groupstringColumn whose values are kept together in one fold (e.g. a county id), so spatially related rows do not leak between folds. Default empty.
learning_ratenumberShrinkage applied to each tree. Default 0.1.
max_iternumberBoosting iterations (trees per class). Default 100.
max_depthnumberMaximum tree depth. Leave empty (the default) for no limit beyond max_leaf_nodes.
max_leaf_nodesnumberMaximum leaves per tree. Default 31.
min_samples_leafnumberMinimum rows in a leaf. Default 20.
l2_regularizationnumberL2 penalty on leaf values. Default 0.

Outputs🔗

NameTypeDescription
modelfile (SpadeModel)The fitted model with its ONNX graph, for models.predict.
fitjsonRows used and dropped, the arguments that shaped the fit, and metrics: rmse, mae, r_squared (regression) or accuracy, log_loss (classification), with cv_ versions when cross-validated.

Example🔗

- id: "@fit"
  name: ml.gradient_boosting
  inputs:
    - "@plots"
  args:
    target: "present"
    features: "elevation_m,canopy_cover_pct,forest_type"
    task: "classification"
    cv_folds: 5