treeboost

package module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Treeboost: High-Performance GBDT & Multi-Algorithm Ensembles for Go

Go Reference License CI

treeboost is a fast, general-purpose machine learning library in Go for training, evaluating, and serving Gradient Boosted Decision Trees (GBDT) and multi-algorithm tree regression ensembles.


⚡ Highlights

  • Pure Go Core + AVX-512 / AVX2 SIMD: Zero cgo dependencies. Includes handcrafted 512-bit AVX-512 and 256-bit AVX2 FMA assembly kernels (weighted_sum_amd64.s generated via avo) with dynamic runtime CPU feature detection (golang.org/x/sys/cpu) and scalar fallbacks for ARM64 and non-AVX platforms.
    • Contiguous Operations: Uses 512-bit AVX-512 vectors ($N \ge 16$) when available, seamlessly scaling to 256-bit AVX2 ($N \ge 8$) or scalar.
    • Indirect Indexing: Uses tuned 256-bit AVX2 vectors for $16 \le N \le 2048$ and out-of-order scalar pipelining for large arrays, ensuring optimal cache and memory pipeline utilization on all CPU generations.
  • Multi-Algorithm Fusion: Train and blend multiple distinct decision tree architectures within a single unified model:
    • Symmetric Trees (CatBoost): Obliviated decision trees where the same feature split condition is evaluated across an entire depth layer.
    • Leaf-Wise Trees (LightGBM): Best-first tree growth strategy splitting nodes with maximum loss reduction (gain) for rapid convergence.
    • Extremely Randomized Trees (ExtraTrees): Randomized feature cut-points that damp down variance and combat overfitting.
  • Histogram Quantization: 256-bin equal-frequency feature quantization (uint8 bin IDs) for $O(\text{numBins})$ histogram split finding.
  • Zero-Allocation Execution: Pooled workspace buffers (sync.Pool), Structure-of-Arrays (ColumnarDataset), and in-place sample partitioning.
  • Vectorized Batch Inference: PredictBatch evaluates multi-tree ensembles across sample batches with 0 heap allocations.
  • Serialization: Native JSON model serialization (SaveModel / LoadModel).

📦 Installation

go get github.com/Noddy76/treeboost

🚀 Quick-Start Guide

1. Training a Multi-Algorithm Ensemble
package main

import (
	"fmt"
	"log"

	"github.com/Noddy76/treeboost"
)

func main() {
	// 1. Prepare Training Features (X) and Targets (Y)
	X := []treeboost.FeatureVector{
		{Values: []float64{10.0, 50.0}},
		{Values: []float64{15.0, 30.0}},
		{Values: []float64{25.0, 10.0}},
		{Values: []float64{30.0, 5.0}},
	}
	Y := []float64{100.0, 80.0, 40.0, 20.0}

	// 2. Configure Ensemble Parameters
	config := treeboost.DefaultEnsembleConfig()
	config.CatBoost.Iterations = 100
	config.LightGBM.Estimators = 100
	config.ExtraTrees.Estimators = 100

	// 3. Train Model
	model := treeboost.TrainEnsemble(X, Y, config)
	fmt.Printf("Model trained! R^2: %.4f, MAE: %.4f, RMSE: %.4f\n", model.RSquared, model.MAE, model.RMSE)

	// 4. Predict Single Observation
	pred := model.Predict([]float64{20.0, 20.0})
	fmt.Printf("Predicted Value: %.2f\n", pred)

	// 5. Predict Batch (Zero-Alloc Vectorized)
	flatFeatures := []float64{
		10.0, 50.0,
		25.0, 10.0,
	}
	batchPreds := model.PredictBatch(flatFeatures, 2)
	fmt.Printf("Batch Predictions: %v\n", batchPreds)

	// 6. Save & Load Model
	if err := model.SaveModel("model.json"); err != nil {
		log.Fatal(err)
	}
	loadedModel, err := treeboost.LoadModel("model.json")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Loaded model prediction: %.2f\n", loadedModel.Predict([]float64{20.0, 20.0}))
}
2. Training Individual GBDT Algorithms

You can also train individual tree algorithms standalone:

W := treeboost.ComputeSampleWeights(Y)

// CatBoost (Symmetric Obliviated Trees)
cbTrees, cbBase := treeboost.TrainSymmetricGBDT(X, Y, W, treeboost.CatBoostParams{
	Depth:        6,
	Iterations:   200,
	LearningRate: 0.05,
	L2LeafReg:    3.0,
})

// LightGBM (Leaf-Wise Best-First Trees)
lgbTrees, lgbBase := treeboost.TrainLeafwiseGBDT(X, Y, W, treeboost.LightGBMParams{
	MaxDepth:        6,
	MaxLeaves:       31,
	MinChildSamples: 20,
	Estimators:      200,
	LearningRate:    0.05,
	L2LeafReg:       1.0,
})

// ExtraTrees (Extremely Randomized Trees)
etTrees := treeboost.TrainExtraTrees(X, Y, W, treeboost.ExtraTreesParams{
	Estimators:     300,
	MinSamplesLeaf: 4,
	MaxFeatures:    1.0,
})

📊 Benchmarks

Run benchmarks locally:

make bench
# or: go test -v -bench=. -benchmem ./...
1. Vectorized Memory Bandwidth & Latency ($N=1,024$)
Kernel Scalar (No SIMD) AVX2 (256-bit) AVX-512 (512-bit) AVX-512 vs Scalar AVX-512 vs AVX2
WeightedSumContiguous $345.9\text{ ns}$ ($47\text{ GB/s}$) $162.9\text{ ns}$ ($100\text{ GB/s}$) $95.5\text{ ns}$ ($171.6\text{ GB/s}$) $3.62\times$ faster $1.71\times$ faster
WeightedSumIndirect ($N=256$) $219.3\text{ ns}$ $101.4\text{ ns}$ $100.6\text{ ns}$ $2.18\times$ faster $1.01\times$
WeightedSumIndirect ($N=1,024$) $923.7\text{ ns}$ $381.3\text{ ns}$ $377.4\text{ ns}$ $2.45\times$ faster $1.01\times$
2. End-to-End Ensemble Training & Inference
Benchmark Latency Memory / Allocs Notes
BenchmarkGBDTPredict (Single Sample) 2.56 µs/op 0 B/op, 0 allocs Real-time serving latency
BenchmarkPredictBatch (64 Samples) 245 µs/op 512 B/op, 1 alloc Multi-sample batch scoring
BenchmarkGBDTTrainEnsemble (AVX-512) 71.5 ms/op 2.93 MB/op, 859 allocs Full CatBoost + LightGBM + ExtraTrees
BenchmarkGBDTTrainEnsemble (AVX2-Only) 72.3 ms/op 2.93 MB/op, 859 allocs Automatic seamless fallback

Dynamic SIMD Dispatch: Treeboost dynamically detects CPU flags at startup (HasAVX512, HasAVX2, HasFMA). Contiguous data paths maximize 512-bit vector throughput, while indirect index paths leverage tuned 256-bit AVX2 kernels and out-of-order execution, ensuring top performance across all Intel and AMD x86-64 hardware.


🛠️ Regenerating SIMD Assembly

The pre-generated assembly file weighted_sum_amd64.s is included directly in the repository so no special tools are needed for standard builds. If you modify the assembly generator, regenerate it using:

go generate ./...
# or: go run ./cmd/gen_simd -out weighted_sum_amd64.s

📚 Theoretical Background & References

  1. Gradient Boosting: Wikipedia - Gradient Boosting — Numerical optimization framework iteratively fitting weak trees to negative loss gradients.
  2. Symmetric Decision Trees (CatBoost): Wikipedia - CatBoost — Obliviated trees evaluating identical split conditions across all nodes at depth $d$.
  3. Leaf-wise Decision Trees (LightGBM): Wikipedia - LightGBM — Best-first tree expansion strategy splitting nodes with maximum loss reduction.
  4. Extremely Randomized Trees (ExtraTrees): Wikipedia - Random Forest / ExtraTrees — Randomizing feature thresholds to reduce variance.

📄 License

Licensed under the Apache License, Version 2.0.

Documentation

Overview

Package treeboost provides a general-purpose, high-performance Gradient Boosted Decision Trees (GBDT) and multi-algorithm ensemble regression library in pure Go with AVX2 SIMD acceleration.

Theoretical Background & Inspiration: The GBDT algorithms and ensemble architectures in this package are inspired by and follow the mathematical formulations detailed in:

Index

Constants

View Source
const DefaultMaxLeafValue = 1e4

DefaultMaxLeafValue defines the default ceiling on individual tree leaf predictions (1e4).

View Source
const DefaultMaxValidPrediction = 1e6

DefaultMaxValidPrediction defines the default ceiling on valid out-of-fold predictions (1e6).

Variables

View Source
var DefaultHorizonBins = []string{"0-6h", "6-12h", "12-24h", "24-36h", "36-48h", ">48h"}

Standard 6 horizon bin names

View Source
var ExtendedHorizonBins = []string{"0-6h", "6-12h", "12-24h", "24-36h", "36-48h", "48-96h", "96-168h", ">168h"}

Extended 8 horizon bin names for medium-term / multi-week forecasts

Functions

func BuildHistogram

func BuildHistogram(bins []uint8, fOffset int, weights []float64, targets []float64, indices []int, hist *FeatureHistogram)

BuildHistogram accumulates sample weights and targets into a FeatureHistogram.

func BuildHistogramSlice

func BuildHistogramSlice(bins []uint8, fOffset int, weights []float64, targets []float64, sampleIdxs []int, start, end int, hist *FeatureHistogram)

BuildHistogramSlice accumulates sample weights and targets over sampleIdxs[start:end] without slice allocations.

func ChronologicalCV added in v0.2.0

func ChronologicalCV(
	X []FeatureVector,
	Y []float64,
	timestamps []time.Time,
	config EnsembleConfig,
	numFolds int,
	leadTimeFeatureIndex int,
) (HorizonOffsets, CVMetrics, error)

ChronologicalCV performs numFolds forward-chaining rolling-origin cross-validation on chronological data. In split k, it trains on folds 0..k-1 and validates on fold k using simulated forecast origin (timestamps[trainEnd-1]). It extracts empirical 10th and 90th percentile residuals per horizon bin, enforces monotonic expansion (uncertainty band widens as horizon increases), and returns the offsets and overall CV metrics.

func ChronologicalCVWithOptions added in v0.3.0

func ChronologicalCVWithOptions(
	X []FeatureVector,
	Y []float64,
	timestamps []time.Time,
	config EnsembleConfig,
	opts ChronologicalCVOptions,
) (HorizonOffsets, CVMetrics, error)

ChronologicalCVWithOptions performs forward-chaining rolling-origin cross-validation with custom options.

func ComputeSampleWeights

func ComputeSampleWeights(Y []float64) []float64

ComputeSampleWeights calculates weights for observations using default log-distance from target mean, emphasizing and penalizing extreme spikes/troughs.

func ComputeSampleWeightsWithConfig added in v0.2.0

func ComputeSampleWeightsWithConfig(Y []float64, cfg WeightConfig) []float64

ComputeSampleWeightsWithConfig calculates weights for observations using a log-distance from the target mean according to the provided WeightConfig. If y < 0, the weight is scaled by cfg.NegativeMultiplier.

func EvaluateTree

func EvaluateTree(nodes []Node, x FeatureVector) float64

EvaluateTree traverses a slice of decision tree nodes from root (node index 0) down to a leaf node for the given feature vector x, returning the leaf's prediction value.

func EvaluateTreeColumnar

func EvaluateTreeColumnar(nodes []Node, data ColumnarDataset, sampleIdx int) float64

EvaluateTreeColumnar evaluates a tree on sampleIdx within ColumnarDataset without allocations.

func FindBestHistogramSplit

func FindBestHistogramSplit(hist *FeatureHistogram, boundaries []float64, totalW, totalWY float64) (float64, float64, bool)

FindBestHistogramSplit scans accumulated feature histogram bins to find the split threshold minimizing variance (maximizing gain).

func FindBestHistogramSplitWithCounts

func FindBestHistogramSplitWithCounts(hist *FeatureHistogram, boundaries []float64, totalW, totalWY float64, totalCount int, minChildSamples int) (splitVal float64, score float64, leftW float64, leftWY float64, rightW float64, rightWY float64, found bool)

FindBestHistogramSplitWithCounts evaluates the optimal split threshold and partition metrics directly from histogram bins.

func HorizonBinForLeadTime added in v0.2.0

func HorizonBinForLeadTime(leadHours float64) int

HorizonBinForLeadTime returns the 0-indexed bin (0 to 5) for a given lead time in hours. Boundaries: [0, 6), [6, 12), [12, 24), [24, 36), [36, 48), [48, inf).

func HorizonBinForLeadTimeWithBins added in v0.3.0

func HorizonBinForLeadTimeWithBins(leadHours float64, bins []string) int

HorizonBinForLeadTimeWithBins returns the 0-indexed bin for a given lead time in hours according to the supplied slice of horizon bin names. If bins is nil or empty, DefaultHorizonBins is used.

func ScaleTreeLeavesInPlace

func ScaleTreeLeavesInPlace(tree *Tree, factor float64)

ScaleTreeLeavesInPlace scales tree leaf values in place without allocating a new slice.

Types

type BinnedDataset

type BinnedDataset struct {
	NumSamples    int
	NumFeatures   int
	MaxBins       int
	Bins          []uint8     // Size (NumFeatures * NumSamples)
	BinBoundaries [][]float64 // Bin upper bound thresholds per feature [NumFeatures][]float64
	BinCounts     []int       // Actual number of bins created per feature [NumFeatures]int
}

BinnedDataset represents a tabular dataset whose continuous features are quantized into discrete 8-bit bin IDs (0..maxBins-1) for fast histogram-based GBDT tree building.

func QuantizeDataset

func QuantizeDataset(data ColumnarDataset, maxBins int) BinnedDataset

QuantizeDataset builds a BinnedDataset from a ColumnarDataset using equal-frequency quantile binning.

type CVMetrics added in v0.2.0

type CVMetrics struct {
	ValidationMAE     float64 `json:"validation_mae"`
	ValidationRMSE    float64 `json:"validation_rmse"`
	RSquared          float64 `json:"r_squared"`
	ValidationSamples int     `json:"validation_samples,omitempty"`
}

CVMetrics holds aggregated out-of-fold cross-validation performance metrics.

type CatBoostParams

type CatBoostParams struct {
	Depth        int     `json:"depth"`
	Iterations   int     `json:"iterations"`
	LearningRate float64 `json:"learning_rate"`
	L2LeafReg    float64 `json:"l2_leaf_reg"`
	MaxLeafValue float64 `json:"max_leaf_value,omitempty"`
}

CatBoostParams holds hyperparameters for Symmetric GBDT (obliviated trees). Reference: https://en.wikipedia.org/wiki/CatBoost

type ChronologicalCVOptions added in v0.3.0

type ChronologicalCVOptions struct {
	NumFolds             int
	LeadTimeFeatureIndex int             // Feature index where (slotTime - originTime)/24h is injected, or -1 to skip
	MaxLeadHours         float64         // Max forward horizon in hours to evaluate (<= 0.0 means unlimited)
	InferenceOverrides   map[int]float64 // Map of feature index -> constant value to override at validation time
	HorizonBins          []string        // Optional custom horizon bin names (defaults to DefaultHorizonBins if nil/empty)
	SampleWeightsConfig  *WeightConfig   // Optional sample weight config for fold training (nil uses DefaultWeightConfig)
	MaxValidPrediction   float64         // Max valid prediction value (defaults to 1e6 when unset or <= 0.0)
}

ChronologicalCVOptions configures chronological rolling-origin cross-validation.

type ColumnarDataset

type ColumnarDataset struct {
	NumSamples  int
	NumFeatures int
	Features    []float64 // Size (NumFeatures * NumSamples)
	Targets     []float64 // Size NumSamples
	Weights     []float64 // Size NumSamples
	Binned      BinnedDataset
}

ColumnarDataset holds dataset features in a flattened Structure of Arrays (SoA) layout. Feature f for sample i is accessed at index f * NumSamples + i.

func ToColumnar

func ToColumnar(X []FeatureVector, Y []float64, W []float64) ColumnarDataset

ToColumnar converts legacy AoS feature vectors ([]FeatureVector) into flattened SoA ColumnarDataset.

type Dataset

type Dataset struct {
	X []FeatureVector
	Y []float64
	W []float64
}

Dataset represents a tabular dataset of feature vectors, target regression values, and optional sample weights.

type EnsembleConfig

type EnsembleConfig struct {
	MaxLeafValue     float64          `json:"max_leaf_value,omitempty"`
	CatBoostWeight   float64          `json:"catboost_weight"`
	LightGBMWeight   float64          `json:"lightgbm_weight"`
	ExtraTreesWeight float64          `json:"extratrees_weight"`
	CatBoost         CatBoostParams   `json:"catboost"`
	LightGBM         LightGBMParams   `json:"lightgbm"`
	ExtraTrees       ExtraTreesParams `json:"extratrees"`
}

EnsembleConfig specifies individual algorithm parameters and weighted contribution ratios.

func DefaultEnsembleConfig

func DefaultEnsembleConfig() EnsembleConfig

DefaultEnsembleConfig returns a balanced, standard default configuration combining Symmetric GBDT, Leaf-wise GBDT, and ExtraTrees into an equal-weight ensemble.

type ExtraTreesParams

type ExtraTreesParams struct {
	Estimators     int     `json:"estimators"`
	MinSamplesLeaf int     `json:"min_samples_leaf"`
	MaxFeatures    float64 `json:"max_features"`
	MaxLeafValue   float64 `json:"max_leaf_value,omitempty"`
}

ExtraTreesParams holds hyperparameters for Extremely Randomized Trees. Reference: https://en.wikipedia.org/wiki/Random_forest#ExtraTrees

type FeatureHistogram

type FeatureHistogram struct {
	Count [256]int
	SumW  [256]float64
	SumWY [256]float64
}

FeatureHistogram holds accumulated count, weight, and weighted target sums across 256 discrete bins.

func (*FeatureHistogram) Reset

func (h *FeatureHistogram) Reset()

Reset zeroes out histogram accumulators.

type FeatureVector

type FeatureVector struct {
	Values []float64
}

FeatureVector represents an n-dimensional sample observation vector of floating-point features.

type HorizonOffsets added in v0.2.0

type HorizonOffsets struct {
	P10 []float64 `json:"p10"`
	P90 []float64 `json:"p90"`
}

HorizonOffsets holds empirical residual quantiles partitioned across horizon bins.

type LightGBMParams

type LightGBMParams struct {
	MaxDepth        int     `json:"max_depth"`
	MaxLeaves       int     `json:"max_leaves"`
	MinChildSamples int     `json:"min_child_samples"`
	Estimators      int     `json:"estimators"`
	LearningRate    float64 `json:"learning_rate"`
	L2LeafReg       float64 `json:"l2_leaf_reg"` // L2 leaf regularization parameter (lambda >= 0.0)
	MaxLeafValue    float64 `json:"max_leaf_value,omitempty"`
}

LightGBMParams holds hyperparameters for Leaf-wise GBDT (best-first tree growth). Reference: https://en.wikipedia.org/wiki/LightGBM

type Model

type Model struct {
	ID              int       `json:"-"`
	TrainedAt       time.Time `json:"trained_at"`
	TrainingStart   time.Time `json:"training_start"`
	TrainingEnd     time.Time `json:"training_end"`
	BaseValue       float64   `json:"base_value"`
	Trees           []Tree    `json:"trees"`
	LearningRate    float64   `json:"learning_rate"`
	MAE             float64   `json:"mae"`
	RMSE            float64   `json:"rmse"`
	RSquared        float64   `json:"r_squared"`
	HorizonBins     []string  `json:"horizon_bins,omitempty"`
	P10Offsets      []float64 `json:"p10_offsets,omitempty"`
	P90Offsets      []float64 `json:"p90_offsets,omitempty"`
	DiagnosticsJSON string    `json:"diagnostics_json,omitempty"`
}

Model represents a trained ensemble model comprising decision trees, a base initial prediction value, learning rate, and evaluation / diagnostic metadata.

func LoadModel

func LoadModel(path string) (*Model, error)

LoadModel loads a serialized GBDT model from a JSON file and validates its integrity.

func TrainEnsemble

func TrainEnsemble(X []FeatureVector, Y []float64, config EnsembleConfig) *Model

TrainEnsemble trains a multi-algorithm tree ensemble combining CatBoost, LightGBM, and ExtraTrees models.

func TrainEnsembleWithWeights added in v0.2.0

func TrainEnsembleWithWeights(X []FeatureVector, Y []float64, W []float64, config EnsembleConfig) *Model

TrainEnsembleWithWeights trains a multi-algorithm tree ensemble (CatBoost, LightGBM, ExtraTrees) using explicit sample weights W.

func (*Model) ComputeMetrics

func (m *Model) ComputeMetrics(X []FeatureVector, Y []float64)

ComputeMetrics evaluates MAE, RMSE, and R^2 of the Model on feature vectors X and targets Y, updating the model's MAE, RMSE, and RSquared fields.

func (*Model) Predict

func (m *Model) Predict(features []float64) float64

Predict evaluates the GBDT model on a slice of feature values and returns the predicted scalar result. It initializes with the BaseValue and adds the weighted leaf prediction from each decision tree in the ensemble.

func (*Model) PredictBatch

func (m *Model) PredictBatch(features []float64, nSamples int) []float64

PredictBatch evaluates the GBDT model on a batch of nSamples feature vectors. features is a flattened slice of length (nSamples * nFeatures) in row-major layout (where sample i feature f is at index i*nFeatures + f). Returns a slice of predicted values of length nSamples.

func (*Model) PredictBatchInterval added in v0.2.0

func (m *Model) PredictBatchInterval(flatFeatures []float64, leadHours []float64) (p10, p50, p90 []float64)

PredictBatchInterval evaluates batch feature vectors with corresponding lead times.

func (*Model) PredictInterval added in v0.2.0

func (m *Model) PredictInterval(features []float64, leadHours float64) (p10, p50, p90 float64)

PredictInterval evaluates the model and applies empirical horizon residual offsets, returning (P10, P50, P90). Unconditionally guarantees P10 <= P50 <= P90 under all conditions (including negative targets) by clamping raw offsets.

func (*Model) SaveModel

func (m *Model) SaveModel(path string) error

SaveModel serializes and writes the GBDT model to a JSON file.

func (*Model) Validate added in v0.4.0

func (m *Model) Validate() error

Validate checks model invariants: finite BaseValue, valid LearningRate, and structural integrity of all trees.

type Node

type Node struct {
	NodeID       int     `json:"node_id"`
	SplitFeature int     `json:"split_feature"` // -1 if leaf node; feature index 0..N-1 otherwise
	SplitValue   float64 `json:"split_value"`
	LeafValue    float64 `json:"leaf_value"`
	LeftChild    int     `json:"left_child"`
	RightChild   int     `json:"right_child"`
}

Node represents a single decision node or leaf node within a decision tree.

func (Node) IsLeaf

func (n Node) IsLeaf() bool

IsLeaf returns true if the node is a leaf node.

type Regressor

type Regressor interface {
	Predict(features []float64) float64
}

Regressor defines the common interface for models capable of generating continuous scalar predictions.

type TrainWorkspace

type TrainWorkspace struct {
	SampleIdxs []int
	PermBuf    []int
	SplitBuf   []float64
	Ranges     []nodeRange
	Hist       FeatureHistogram
}

TrainWorkspace holds reusable slice buffers to eliminate heap allocations during tree construction.

type Tree

type Tree struct {
	Nodes []Node `json:"nodes"`
}

Tree represents a single decision tree composed of ordered nodes.

func ScaleTreeLeaves

func ScaleTreeLeaves(tree Tree, factor float64) Tree

ScaleTreeLeaves returns a deep copy of tree with all leaf node values multiplied by factor.

func TrainExtraTrees

func TrainExtraTrees(X []FeatureVector, Y []float64, W []float64, params ExtraTreesParams) []Tree

TrainExtraTrees fits an Extremely Randomized Trees (ExtraTrees) regression ensemble.

func TrainExtraTreesColumnar

func TrainExtraTreesColumnar(data ColumnarDataset, params ExtraTreesParams) []Tree

TrainExtraTreesColumnar fits an ExtraTrees regression ensemble on ColumnarDataset without per-iteration conversions.

func TrainLeafwiseGBDT

func TrainLeafwiseGBDT(X []FeatureVector, Y []float64, W []float64, params LightGBMParams) ([]Tree, float64)

TrainLeafwiseGBDT fits a leaf-wise (LightGBM-style) gradient boosted decision tree ensemble.

func TrainLeafwiseGBDTColumnar

func TrainLeafwiseGBDTColumnar(data ColumnarDataset, params LightGBMParams) ([]Tree, float64)

TrainLeafwiseGBDTColumnar fits a leaf-wise GBDT on ColumnarDataset without per-iteration conversions.

func TrainSymmetricGBDT

func TrainSymmetricGBDT(X []FeatureVector, Y []float64, W []float64, params CatBoostParams) ([]Tree, float64)

TrainSymmetricGBDT fits a symmetric (CatBoost-style) gradient boosted decision tree ensemble.

func TrainSymmetricGBDTColumnar

func TrainSymmetricGBDTColumnar(data ColumnarDataset, params CatBoostParams) ([]Tree, float64)

TrainSymmetricGBDTColumnar fits a CatBoost-style GBDT on ColumnarDataset without per-iteration conversions.

func (Tree) Evaluate

func (t Tree) Evaluate(features []float64) float64

Evaluate evaluates a single decision tree on a feature vector.

type WeightConfig added in v0.2.0

type WeightConfig struct {
	Multiplier         float64 // default: 5.0
	Offset             float64 // default: 10.0
	Subtrahend         float64 // default: 4.0
	MinWeight          float64 // default: 1.0
	NegativeMultiplier float64 // default: 1.0 (e.g., set to 1.5 for 1.5x plunge penalty on y < 0)
}

WeightConfig specifies parameters for sample weight computation.

func DefaultWeightConfig added in v0.2.0

func DefaultWeightConfig() WeightConfig

DefaultWeightConfig returns the default weighting parameters.

Directories

Path Synopsis
cmd
gen_simd command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL