Browse documentation
aner.ml · Reference

Histogram gradient boosting

Fit numerical trees for regression or binary classification with bins learned from training observations.

ImplementedAner 0.1.0 or newer

Aner 0.0.8 adds boosted numerical trees for regression and binary classification. Fitting learns bin boundaries from a protected training AdaptiveFrame, then adds trees that improve the selected objective. Fitted predictions retain observation IDs. Regression predictions retain the target unit, and binary probabilities are dimensionless.

Run the device alert example from the source root.

sh
aner check examples/histogram_alerts.aner
aner run examples/histogram_alerts.aner

Use the same plan for grouped cross validation and the final fit.

aner
let plan = ml.histogram_boosting(objective: "log_loss", iterations: 40)
let fold_losses = plan.cross_validate(parts.train(), folds: 5, seed: 42)
let model = plan.fit(parts.train())
print(model.evaluate(parts.test()))
OperationBehavior
ml.histogram_boosting(objective: "squared_error", iterations: 100, learning_rate: 0.1, max_leaves: 31, min_leaf: 20, max_bins: 255, l2: 0.0)Creates a HistogramBoostPlan. Each setting may be supplied independently.
plan.fit(training, max_bytes: 67108864, workers: 0)Returns a FittedHistogramBoost from an authorized training view.
plan.cross_validate(training, folds: 5, seed: 42, workers: 0)Returns one held out score per fold. Each fold learns its own bins and fits its own trees.
model.predict(observations)Returns contextual regression values or binary labels.
model.predict_proba(observations)Returns one probability of class 1 per row for a binary model.
model.evaluate(held_out)Returns RMSE for regression or mean log loss for binary classification on validation or test rows in the fitted experiment.
model.align_inputs(observations, columns)Maps present numerical features in independent unlabeled observations into fitted order, applying compatible unit conversions.
model.iterations(), model.summary()Report the fitted tree count and model settings.
model.save(path), ml.load_histogram_boosting(path, training_anchor, max_bytes: 67108864, workers: 0)Save a refit checkpoint and verify the resulting ensemble against its fingerprint when reopening it with a matching trusted training view.

The default squared error objective accepts a numerical target. Use objective: "log_loss" for an exact dimensionless 0/1 target. Both classes must occur in binary training, including the training split of each fold. A held out split may contain one class. Targets must be present. The booster learns where to route missing numerical features. Explicit external alignment requires present inputs.

The fitted ensemble begins with the training mean for regression or the training log odds for classification. Each round grows a tree using the training gradients and Hessians. The learning rate scales each new tree's contribution. min_leaf sets the minimum number of observations in a child, max_leaves bounds tree size, and l2 regularizes leaf weights. When a split saw no missing values during training, it sends a missing prediction value to the child with more training rows, choosing left on a tie. Choose the number of rounds using training and validation populations, and keep the final test population separate.

The plan accepts 1 to 1,000 rounds, 1 to 255 leaves per tree, a minimum leaf size of 1 to 1,000,000, and 2 to 255 bins. The learning rate must be finite and in (0, 1], and l2 must be finite and nonnegative.

Fits run on CPU Float64 and store admitted feature bins in a compact matrix with one byte per feature value. A separate bin represents missing values. Binning sorts one numerical feature column at a time and assigns its bins in one pass over the sorted values. The tree builder reuses histograms and derives a sibling histogram by subtraction. For fit, grouped validation, and checkpoint reload, workers: 0 selects workers automatically within the available CPU budget. Set workers: 1 for a serial fit. Larger values cap the workers used for eligible workloads, up to 16. A request above the available CPU budget is rejected. Grouped validation fits one fold at a time, so the limit applies within each fold. Split and reduction order stay deterministic across worker settings, and model.summary() reports the requested and effective worker counts. The same managed byte budget covers the binned matrix, numerical training scratch, fitted membership, and retained ensemble at every worker count. The input table, contextual metadata, worker runtime overhead, and allocator overhead are outside that budget. Reload verifies the ensemble by recomputing the fit, so it requires the training view and fitting budget.

See the Machine learning module reference for the shared API.

Aner documentation · Reference and guides