otter-streams-xgboost
Gradient Boosting
High-performance gradient boosting inference for trained models from tabular datasets
Module Overview
The XGBoost module provides native XGBoost inference optimized for tabular and structured data problems. It supports multiple model formats, batch predictions, and GPU acceleration for high-throughput gradient boosting inference.
XGBoost Engine
Gradient BoostingNative XGBoost inference optimized for tabular and structured data problems.
- Binary, JSON, and UBJSON model formats
- Regression, binary, and multi-class classification
- Efficient batch prediction via DMatrix
- GPU acceleration when available
Performance Features
OptimizationAdvanced performance optimizations for high-throughput inference.
- Thread-safe Booster predictions
- Column-major DMatrix for efficiency
- Native missing value handling (NaN)
- Automatic memory management
Implementing XGBoost Inference
Guide to deploying XGBoost models for real-time predictions.
-
Add Maven Dependency
<dependency> <groupId>com.codedstreams</groupId> <artifactId>otter-streams-xgboost</artifactId> <version>1.0.16</version> </dependency> -
Train and Save XGBoost Model
import xgboost as xgb # Train model dtrain = xgb.DMatrix(X_train, label=y_train) params = {'objective': 'binary:logistic', 'max_depth': 3} model = xgb.train(params, dtrain, num_boost_round=100) # Save in binary format (fastest) model.save_model('model.bin') # Or save in JSON format (portable) model.save_model('model.json') -
Configure and Use Engine
ModelConfig config = ModelConfig.builder() .modelPath("model.xgb") .modelId("xgboost-classifier") .format(ModelFormat.XGBOOST_BINARY) .build(); XGBoostInferenceEngine engine = new XGBoostInferenceEngine(); engine.initialize(config); // Single prediction Map<String, Object> inputs = Map.of( "age", 35.0f, "income", 75000.0f, "credit_score", 720.0f ); InferenceResult result = engine.infer(inputs); float prediction = (float) result.getOutput("prediction"); -
Batch Predictions
// Batch inference for efficiency Map<String, Object>[] batchInputs = new Map[1000]; // ... populate batch inputs InferenceResult batchResult = engine.inferBatch(batchInputs); float[][] predictions = (float[][]) batchResult.getOutput("batch_predictions");
Maven Dependency
<dependency>
<groupId>com.codedstreams</groupId>
<artifactId>otter-streams-xgboost</artifactId>
<version>1.0.16</version>
</dependency>