Models¶
All OpenBoost model classes.
Standard GBDT¶
GradientBoosting¶
GradientBoosting
dataclass
¶
GradientBoosting(
n_trees=100,
max_depth=6,
learning_rate=0.1,
loss="mse",
min_child_weight=1.0,
reg_lambda=1.0,
reg_alpha=0.0,
gamma=0.0,
subsample=1.0,
colsample_bytree=1.0,
n_bins=256,
quantile_alpha=0.5,
tweedie_rho=1.5,
distributed=False,
n_workers=None,
subsample_strategy="none",
goss_top_rate=0.2,
goss_other_rate=0.1,
batch_size=None,
n_gpus=None,
devices=None,
)
Bases: PersistenceMixin
Gradient Boosting ensemble model.
A gradient boosting model that supports both built-in loss functions and custom loss functions. When using built-in losses with GPU, training is fully batched for maximum performance.
| PARAMETER | DESCRIPTION |
|---|---|
n_trees
|
Number of trees to train.
TYPE:
|
max_depth
|
Maximum depth of each tree.
TYPE:
|
learning_rate
|
Shrinkage factor applied to each tree.
TYPE:
|
loss
|
Loss function. Can be: - 'mse': Mean Squared Error (regression) - 'logloss': Binary cross-entropy (classification) - 'huber': Huber loss (robust regression) - 'mae': Mean Absolute Error (L1 regression) - 'quantile': Quantile regression (use with quantile_alpha) - Callable: Custom function(pred, y) -> (grad, hess)
TYPE:
|
min_child_weight
|
Minimum sum of hessian in a leaf.
TYPE:
|
reg_lambda
|
L2 regularization on leaf values.
TYPE:
|
n_bins
|
Number of bins for histogram building.
TYPE:
|
quantile_alpha
|
Quantile level for 'quantile' loss (0 < alpha < 1). - 0.5: Median regression (default) - 0.9: 90th percentile - 0.1: 10th percentile
TYPE:
|
tweedie_rho
|
Variance power for 'tweedie' loss (1 < rho < 2). - 1.5: Default (compound Poisson-Gamma)
TYPE:
|
subsample_strategy
|
Sampling strategy for large-scale training (Phase 17): - 'none': No sampling (default) - 'random': Random subsampling - 'goss': Gradient-based One-Side Sampling (LightGBM-style)
TYPE:
|
goss_top_rate
|
Fraction of top-gradient samples to keep (for GOSS).
TYPE:
|
goss_other_rate
|
Fraction of remaining samples to sample (for GOSS).
TYPE:
|
batch_size
|
Mini-batch size for large datasets. If None, process all at once.
TYPE:
|
Examples:
Basic regression:
import openboost as ob
model = ob.GradientBoosting(n_trees=100, loss='mse')
model.fit(X_train, y_train)
predictions = model.predict(X_test)
Quantile regression (90th percentile):
GOSS for faster training:
model = ob.GradientBoosting(
n_trees=100,
subsample_strategy='goss',
goss_top_rate=0.2,
goss_other_rate=0.1,
)
Multi-GPU training:
fit
¶
Fit the gradient boosting model.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Training features, shape (n_samples, n_features).
TYPE:
|
y
|
Training targets, shape (n_samples,).
TYPE:
|
callbacks
|
List of Callback instances for training hooks. Use EarlyStopping for early stopping, Logger for progress.
TYPE:
|
eval_set
|
List of (X, y) tuples for validation (used with callbacks).
TYPE:
|
sample_weight
|
Sample weights, shape (n_samples,).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
self
|
The fitted model.
TYPE:
|
predict
¶
Generate predictions for X.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Features to predict on, shape (n_samples, n_features). Can be raw numpy array or pre-binned BinnedArray.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
predictions
|
Shape (n_samples,).
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If model is not fitted or X has wrong shape. |
MultiClassGradientBoosting¶
MultiClassGradientBoosting
dataclass
¶
MultiClassGradientBoosting(
n_classes,
n_trees=100,
max_depth=6,
learning_rate=0.1,
min_child_weight=1.0,
reg_lambda=1.0,
reg_alpha=0.0,
gamma=0.0,
subsample=1.0,
colsample_bytree=1.0,
n_bins=256,
subsample_strategy="none",
goss_top_rate=0.2,
goss_other_rate=0.1,
batch_size=None,
)
Bases: PersistenceMixin
Multi-class Gradient Boosting classifier.
Uses softmax loss and trains K trees per round (one per class), following the XGBoost/LightGBM approach.
| PARAMETER | DESCRIPTION |
|---|---|
n_classes
|
Number of classes.
TYPE:
|
n_trees
|
Number of boosting rounds (total trees = n_trees * n_classes).
TYPE:
|
max_depth
|
Maximum depth of each tree.
TYPE:
|
learning_rate
|
Shrinkage factor applied to each tree.
TYPE:
|
min_child_weight
|
Minimum sum of hessian in a leaf.
TYPE:
|
reg_lambda
|
L2 regularization on leaf values.
TYPE:
|
n_bins
|
Number of bins for histogram building.
TYPE:
|
subsample_strategy
|
Sampling strategy (Phase 17): 'none', 'random', 'goss'.
TYPE:
|
goss_top_rate
|
Fraction of top-gradient samples to keep (for GOSS).
TYPE:
|
goss_other_rate
|
Fraction of remaining samples to sample (for GOSS).
TYPE:
|
Example
import openboost as ob
model = ob.MultiClassGradientBoosting(n_classes=10, n_trees=100)
model.fit(X_train, y_train) # y_train: 0 to 9
predictions = model.predict(X_test) # Returns class labels
proba = model.predict_proba(X_test) # Returns probabilities
With GOSS sampling:
fit
¶
Fit the multi-class gradient boosting model.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Training features, shape (n_samples, n_features).
TYPE:
|
y
|
Training labels, shape (n_samples,). Integer class labels 0 to n_classes-1.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
self
|
The fitted model. |
predict
¶
Predict class labels.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Features to predict on.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
labels
|
Shape (n_samples,). Integer class labels.
TYPE:
|
predict_proba
¶
Predict class probabilities.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Features to predict on.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
probabilities
|
Shape (n_samples, n_classes).
TYPE:
|
DART¶
DART
dataclass
¶
DART(
n_trees=100,
max_depth=6,
learning_rate=0.1,
loss="mse",
dropout_rate=0.1,
skip_drop=0.0,
normalize=True,
sample_type="uniform",
min_child_weight=1.0,
reg_lambda=1.0,
n_bins=256,
seed=None,
)
Bases: PersistenceMixin
DART: Gradient Boosting with Dropout.
Implements DART (Dropouts meet Multiple Additive Regression Trees), which randomly drops trees during training to prevent overfitting.
| PARAMETER | DESCRIPTION |
|---|---|
n_trees
|
Number of trees to train.
TYPE:
|
max_depth
|
Maximum depth of each tree.
TYPE:
|
learning_rate
|
Base learning rate (shrinkage factor).
TYPE:
|
loss
|
Loss function ('mse', 'logloss', 'huber', or callable).
TYPE:
|
dropout_rate
|
Fraction of trees to drop each round (0 to 1).
TYPE:
|
skip_drop
|
Probability of skipping dropout for a round.
TYPE:
|
normalize
|
If True, normalize dropped tree contributions.
TYPE:
|
sample_type
|
How to sample dropped trees ('uniform' or 'weighted').
TYPE:
|
min_child_weight
|
Minimum sum of hessian in a leaf.
TYPE:
|
reg_lambda
|
L2 regularization on leaf values.
TYPE:
|
n_bins
|
Number of bins for histogram building.
TYPE:
|
seed
|
Random seed for reproducibility.
TYPE:
|
Example
fit
¶
Fit the DART model.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Training features, shape (n_samples, n_features).
TYPE:
|
y
|
Training targets, shape (n_samples,).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
self
|
The fitted model.
TYPE:
|
predict
¶
Generate predictions for X.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Features to predict on, shape (n_samples, n_features). Can be raw numpy array or pre-binned BinnedArray.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
predictions
|
Shape (n_samples,).
TYPE:
|
Interpretable Models¶
OpenBoostGAM¶
OpenBoostGAM
dataclass
¶
Bases: PersistenceMixin
GPU-accelerated Generalized Additive Model.
An interpretable model where
prediction = sum(shape_functioni for all features)
Each shape function is a lookup table mapping binned feature values to contribution scores. Trained via parallel gradient boosting.
| PARAMETER | DESCRIPTION |
|---|---|
n_rounds
|
Number of boosting rounds.
TYPE:
|
learning_rate
|
Shrinkage factor (smaller = more stable, needs more rounds).
TYPE:
|
reg_lambda
|
L2 regularization on leaf values.
TYPE:
|
loss
|
Loss function ('mse', 'logloss', or callable).
TYPE:
|
n_bins
|
Number of bins for histogram building.
TYPE:
|
Example
fit
¶
Fit the GAM model.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Training features, shape (n_samples, n_features).
TYPE:
|
y
|
Training targets, shape (n_samples,).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
self
|
The fitted model.
TYPE:
|
predict
¶
Generate predictions.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Features, shape (n_samples, n_features).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
predictions
|
Shape (n_samples,).
TYPE:
|
get_feature_importance
¶
Get feature importance based on shape function variance.
| RETURNS | DESCRIPTION |
|---|---|
importance
|
Shape (n_features,), higher = more important.
TYPE:
|
plot_shape_function
¶
Plot the shape function for a feature.
| PARAMETER | DESCRIPTION |
|---|---|
feature_idx
|
Index of the feature to plot.
TYPE:
|
feature_name
|
Optional name for the x-axis label.
TYPE:
|
LinearLeafGBDT¶
LinearLeafGBDT
dataclass
¶
LinearLeafGBDT(
n_trees=100,
max_depth=4,
learning_rate=0.1,
loss="mse",
min_samples_leaf=20,
reg_lambda_tree=1.0,
reg_lambda_linear=0.1,
max_features_linear="sqrt",
n_bins=256,
)
Bases: PersistenceMixin
Gradient Boosting with Linear Leaf Trees.
Each tree has linear models in its leaves instead of constant values. This enables: - Better extrapolation beyond training data range - Smoother decision boundaries - Can use shallower trees (linear models add complexity)
Recommended settings: - Use max_depth=3-4 (shallower than standard GBDT) - Use larger min_samples_leaf (need samples to fit linear model)
| PARAMETER | DESCRIPTION |
|---|---|
n_trees
|
Number of boosting rounds
TYPE:
|
max_depth
|
Maximum tree depth (typically 3-4, shallower than standard)
TYPE:
|
learning_rate
|
Shrinkage factor
TYPE:
|
loss
|
Loss function ('mse', 'mae', 'huber', or callable)
TYPE:
|
min_samples_leaf
|
Minimum samples to fit linear model in leaf
TYPE:
|
reg_lambda_tree
|
L2 regularization for tree splits
TYPE:
|
reg_lambda_linear
|
L2 regularization for linear models (ridge)
TYPE:
|
max_features_linear
|
Max features per leaf's linear model - None: Use all features - 'sqrt': Use sqrt(n_features) features - 'log2': Use log2(n_features) features - int: Use exactly this many features
TYPE:
|
n_bins
|
Number of bins for histogram building
TYPE:
|
Example
model = LinearLeafGBDT(n_trees=100, max_depth=4)
model.fit(X_train, y_train)
pred = model.predict(X_test)
# Compare extrapolation with standard GBDT
from openboost import GradientBoosting
standard = GradientBoosting(n_trees=100, max_depth=6)
standard.fit(X_train, y_train)
# LinearLeafGBDT typically extrapolates better on linear trends
fit
¶
Fit the linear leaf GBDT model.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Training features, shape (n_samples, n_features)
TYPE:
|
y
|
Training targets, shape (n_samples,)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
self
|
Fitted model
TYPE:
|
predict
¶
Generate predictions.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Features, shape (n_samples, n_features)
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
predictions
|
Shape (n_samples,)
TYPE:
|
Probabilistic Models (NaturalBoost)¶
NaturalBoost¶
NaturalBoost
dataclass
¶
NaturalBoost(
distribution="normal",
n_trees=100,
max_depth=4,
learning_rate=0.1,
min_child_weight=1.0,
reg_lambda=1.0,
reg_alpha=0.0,
subsample=1.0,
colsample_bytree=1.0,
n_bins=256,
)
Bases: DistributionalGBDT
Natural Gradient Boosting for probabilistic prediction.
OpenBoost's implementation of natural gradient boosting, inspired by NGBoost. Uses natural gradient instead of ordinary gradient, leading to faster convergence by accounting for the geometry of the parameter space.
Natural gradient: F^{-1} @ ordinary_gradient where F is the Fisher information matrix.
Key advantages over standard GBDT: - Full probability distributions, not just point estimates - Prediction intervals and uncertainty quantification - Faster convergence than ordinary gradient descent
Key advantages over official NGBoost: - GPU acceleration via histogram-based trees - Faster on large datasets (>10k samples) - Custom distributions with autodiff support
Reference
Duan et al. "NGBoost: Natural Gradient Boosting for Probabilistic Prediction." ICML 2020.
| PARAMETER | DESCRIPTION |
|---|---|
distribution
|
Distribution name or instance
TYPE:
|
n_trees
|
Number of boosting rounds (often needs fewer than ordinary)
TYPE:
|
max_depth
|
Maximum depth of each tree (default 4, often smaller is better)
TYPE:
|
learning_rate
|
Shrinkage factor
TYPE:
|
min_child_weight
|
Minimum sum of hessian in a leaf
TYPE:
|
reg_lambda
|
L2 regularization
TYPE:
|
n_bins
|
Number of bins for histogram building
TYPE:
|
Example
NaturalBoostNormal¶
NaturalBoostLogNormal¶
NaturalBoostLogNormal
¶
NaturalBoost with LogNormal distribution (for positive data).
NaturalBoostGamma¶
NaturalBoostGamma
¶
NaturalBoost with Gamma distribution (for positive data).
NaturalBoostPoisson¶
NaturalBoostPoisson
¶
NaturalBoost with Poisson distribution (for count data).
NaturalBoostStudentT¶
NaturalBoostStudentT
¶
NaturalBoost with Student-t distribution (for heavy-tailed data).
NaturalBoostTweedie¶
NaturalBoostTweedie
¶
NaturalBoost with Tweedie distribution (for insurance claims, zero-inflated data).
Kaggle Use Cases: - Porto Seguro Safe Driver Prediction - Allstate Claims Severity - Any zero-inflated positive target
| PARAMETER | DESCRIPTION |
|---|---|
power
|
Tweedie power parameter (1 < power < 2). 1.5 is the default for insurance claims.
TYPE:
|
**kwargs
|
Other NaturalBoost parameters (n_trees, learning_rate, etc.)
DEFAULT:
|
NaturalBoostNegBin¶
NaturalBoostNegBin
¶
NaturalBoost with Negative Binomial distribution (for overdispersed count data).
Kaggle Use Cases: - Rossmann Store Sales - Bike Sharing Demand - Grupo Bimbo Inventory Demand - Any count prediction where variance > mean
| PARAMETER | DESCRIPTION |
|---|---|
**kwargs
|
NaturalBoost parameters (n_trees, learning_rate, etc.)
DEFAULT:
|
sklearn Wrappers¶
OpenBoostRegressor¶
OpenBoostRegressor
¶
OpenBoostRegressor(
n_estimators=100,
max_depth=6,
learning_rate=0.1,
loss="squared_error",
min_child_weight=1.0,
reg_lambda=1.0,
reg_alpha=0.0,
gamma=0.0,
subsample=1.0,
colsample_bytree=1.0,
n_bins=256,
quantile_alpha=0.5,
subsample_strategy="none",
goss_top_rate=0.2,
goss_other_rate=0.1,
batch_size=None,
early_stopping_rounds=None,
verbose=0,
random_state=None,
)
Bases: BaseEstimator, RegressorMixin
Gradient Boosting Regressor with sklearn-compatible interface.
This is a thin wrapper around OpenBoost's GradientBoosting that provides full compatibility with sklearn's ecosystem (GridSearchCV, Pipeline, etc.).
Parameters¶
n_estimators : int, default=100 Number of boosting rounds (trees). max_depth : int, default=6 Maximum depth of each tree. learning_rate : float, default=0.1 Shrinkage factor applied to each tree's contribution. loss : {'squared_error', 'absolute_error', 'huber', 'quantile'}, default='squared_error' Loss function to optimize. min_child_weight : float, default=1.0 Minimum sum of hessian in a leaf node. reg_lambda : float, default=1.0 L2 regularization on leaf values. reg_alpha : float, default=0.0 L1 regularization on leaf values. gamma : float, default=0.0 Minimum gain required to make a split. subsample : float, default=1.0 Fraction of samples to use for each tree. colsample_bytree : float, default=1.0 Fraction of features to use for each tree. n_bins : int, default=256 Number of bins for histogram building. quantile_alpha : float, default=0.5 Quantile level for 'quantile' loss. subsample_strategy : {'none', 'random', 'goss'}, default='none' Sampling strategy for large-scale training (Phase 17). - 'none': No sampling (default) - 'random': Random subsampling - 'goss': Gradient-based One-Side Sampling (LightGBM-style) goss_top_rate : float, default=0.2 Fraction of top-gradient samples to keep (for GOSS). goss_other_rate : float, default=0.1 Fraction of remaining samples to sample (for GOSS). batch_size : int, optional Mini-batch size for large datasets. If None, process all at once. early_stopping_rounds : int, optional Stop training if validation score doesn't improve for this many rounds. Requires eval_set to be passed to fit(). verbose : int, default=0 Verbosity level (0=silent, N=log every N rounds). random_state : int, optional Random seed for reproducibility.
Attributes¶
n_features_in_ : int Number of features seen during fit. feature_names_in_ : ndarray of shape (n_features_in_,) Names of features seen during fit (if X is a DataFrame). feature_importances_ : ndarray of shape (n_features_in_,) Feature importances (based on split frequency). booster_ : GradientBoosting The underlying fitted OpenBoost model. best_iteration_ : int Iteration with best validation score (if early stopping used). best_score_ : float Best validation score achieved (if early stopping used).
Examples¶
from openboost import OpenBoostRegressor reg = OpenBoostRegressor(n_estimators=100, max_depth=6) reg.fit(X_train, y_train) reg.predict(X_test) reg.score(X_test, y_test) # R² score
With early stopping¶
reg = OpenBoostRegressor(n_estimators=1000, early_stopping_rounds=50) reg.fit(X_train, y_train, eval_set=[(X_val, y_val)]) print(f"Best iteration: {reg.best_iteration_}")
GridSearchCV¶
from sklearn.model_selection import GridSearchCV param_grid = {'n_estimators': [50, 100], 'max_depth': [3, 5]} search = GridSearchCV(OpenBoostRegressor(), param_grid, cv=5) search.fit(X, y)
fit
¶
Fit the gradient boosting regressor.
Parameters¶
X : array-like of shape (n_samples, n_features) Training features. y : array-like of shape (n_samples,) Target values. sample_weight : array-like of shape (n_samples,), optional Sample weights. eval_set : list of (X, y) tuples, optional Validation sets for early stopping.
Returns¶
self : OpenBoostRegressor Fitted estimator.
OpenBoostClassifier¶
OpenBoostClassifier
¶
OpenBoostClassifier(
n_estimators=100,
max_depth=6,
learning_rate=0.1,
min_child_weight=1.0,
reg_lambda=1.0,
reg_alpha=0.0,
gamma=0.0,
subsample=1.0,
colsample_bytree=1.0,
n_bins=256,
subsample_strategy="none",
goss_top_rate=0.2,
goss_other_rate=0.1,
batch_size=None,
early_stopping_rounds=None,
verbose=0,
random_state=None,
)
Bases: BaseEstimator, ClassifierMixin
Gradient Boosting Classifier with sklearn-compatible interface.
Automatically handles binary and multi-class classification. Uses logloss for binary, softmax for multi-class.
Parameters¶
n_estimators : int, default=100 Number of boosting rounds. max_depth : int, default=6 Maximum depth of each tree. learning_rate : float, default=0.1 Shrinkage factor. min_child_weight : float, default=1.0 Minimum sum of hessian in a leaf. reg_lambda : float, default=1.0 L2 regularization on leaf values. reg_alpha : float, default=0.0 L1 regularization on leaf values. gamma : float, default=0.0 Minimum gain required to make a split. subsample : float, default=1.0 Fraction of samples per tree. colsample_bytree : float, default=1.0 Fraction of features per tree. n_bins : int, default=256 Number of bins for histogram building. subsample_strategy : {'none', 'random', 'goss'}, default='none' Sampling strategy for large-scale training (Phase 17). goss_top_rate : float, default=0.2 Fraction of top-gradient samples to keep (for GOSS). goss_other_rate : float, default=0.1 Fraction of remaining samples to sample (for GOSS). batch_size : int, optional Mini-batch size for large datasets. early_stopping_rounds : int, optional Stop if validation doesn't improve. verbose : int, default=0 Verbosity level. random_state : int, optional Random seed.
Attributes¶
classes_ : ndarray Unique class labels. n_classes_ : int Number of classes. n_features_in_ : int Number of features. feature_importances_ : ndarray Feature importances. booster_ : GradientBoosting or MultiClassGradientBoosting Underlying model.
Examples¶
from openboost import OpenBoostClassifier clf = OpenBoostClassifier(n_estimators=100) clf.fit(X_train, y_train) clf.predict(X_test) clf.predict_proba(X_test) clf.classes_ array([0, 1])
Multi-class¶
clf.fit(X_train, y_train) # y_train has 3+ classes clf.predict_proba(X_test).shape (n_samples, n_classes)
fit
¶
Fit the gradient boosting classifier.
Parameters¶
X : array-like of shape (n_samples, n_features) Training features. y : array-like of shape (n_samples,) Target class labels. sample_weight : array-like of shape (n_samples,), optional Sample weights. eval_set : list of (X, y) tuples, optional Validation sets for early stopping.
Returns¶
self : OpenBoostClassifier Fitted estimator.
predict
¶
OpenBoostDistributionalRegressor¶
OpenBoostDistributionalRegressor
¶
OpenBoostDistributionalRegressor(
distribution="normal",
n_estimators=100,
max_depth=4,
learning_rate=0.1,
min_child_weight=1.0,
reg_lambda=1.0,
n_bins=256,
use_natural_gradient=True,
verbose=0,
)
Bases: BaseEstimator, RegressorMixin
Distributional regression with sklearn-compatible interface.
Predicts full probability distributions instead of point estimates. Uses natural gradient boosting (NGBoost) by default for faster convergence.
Parameters¶
distribution : str, default='normal' Distribution family. Options: 'normal', 'lognormal', 'gamma', 'poisson', 'studentt'. n_estimators : int, default=100 Number of boosting rounds. max_depth : int, default=4 Maximum depth of each tree. Typically shallower than standard GBDT. learning_rate : float, default=0.1 Shrinkage factor. min_child_weight : float, default=1.0 Minimum sum of hessian in a leaf. reg_lambda : float, default=1.0 L2 regularization on leaf values. n_bins : int, default=256 Number of bins for histogram building. use_natural_gradient : bool, default=True If True, use NGBoost (natural gradient). Recommended for faster convergence and better uncertainty calibration. verbose : int, default=0 Verbosity level.
Attributes¶
n_features_in_ : int Number of features seen during fit. booster_ : NGBoost or DistributionalGBDT The underlying fitted model.
Examples¶
from openboost import OpenBoostDistributionalRegressor model = OpenBoostDistributionalRegressor(distribution='normal') model.fit(X_train, y_train)
Point prediction (mean)¶
y_pred = model.predict(X_test)
Prediction intervals (90%)¶
lower, upper = model.predict_interval(X_test, alpha=0.1)
Full distribution parameters¶
params = model.predict_distribution(X_test) mu, sigma = params['loc'], params['scale']
Sample from predicted distribution¶
samples = model.sample(X_test, n_samples=100)
fit
¶
predict
¶
predict_interval
¶
Predict (1-alpha) prediction interval.
Parameters¶
X : array-like of shape (n_samples, n_features) Features to predict on. alpha : float, default=0.1 Significance level. 0.1 gives a 90% prediction interval.
Returns¶
lower : ndarray of shape (n_samples,) Lower bounds of the interval. upper : ndarray of shape (n_samples,) Upper bounds of the interval.
predict_distribution
¶
predict_quantile
¶
sample
¶
Sample from predicted distribution.
Parameters¶
X : array-like of shape (n_obs, n_features) Features to predict on. n_samples : int, default=1 Number of samples per observation. seed : int, optional Random seed for reproducibility.
Returns¶
samples : ndarray of shape (n_obs, n_samples) Samples from the predicted distribution.
OpenBoostLinearLeafRegressor¶
OpenBoostLinearLeafRegressor
¶
OpenBoostLinearLeafRegressor(
n_estimators=100,
max_depth=4,
learning_rate=0.1,
loss="squared_error",
min_samples_leaf=20,
reg_lambda=1.0,
reg_lambda_linear=0.1,
max_features_linear="sqrt",
n_bins=256,
verbose=0,
)
Bases: BaseEstimator, RegressorMixin
Linear Leaf Gradient Boosting with sklearn-compatible interface.
Uses trees with linear models in leaves instead of constant values. This provides better extrapolation beyond the training data range.
Parameters¶
n_estimators : int, default=100 Number of boosting rounds. max_depth : int, default=4 Maximum tree depth. Typically shallower than standard GBDT since linear models in leaves add flexibility. learning_rate : float, default=0.1 Shrinkage factor. loss : str, default='squared_error' Loss function: 'squared_error', 'absolute_error', 'huber'. min_samples_leaf : int, default=20 Minimum samples in a leaf to fit linear model. reg_lambda : float, default=1.0 L2 regularization for tree splits. reg_lambda_linear : float, default=0.1 L2 regularization for linear models in leaves (ridge). max_features_linear : int, str, or None, default='sqrt' Max features for linear model in each leaf: - None: Use all features - 'sqrt': Use sqrt(n_features) - 'log2': Use log2(n_features) - int: Use exactly this many features n_bins : int, default=256 Number of bins for histogram building. verbose : int, default=0 Verbosity level.
Attributes¶
n_features_in_ : int Number of features seen during fit. booster_ : LinearLeafGBDT The underlying fitted model.
Examples¶
from openboost import OpenBoostLinearLeafRegressor model = OpenBoostLinearLeafRegressor(n_estimators=100, max_depth=4) model.fit(X_train, y_train) y_pred = model.predict(X_test)
Compare with standard GBDT on extrapolation tasks¶
LinearLeafRegressor typically performs better when the¶
underlying relationship has linear components¶