![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
github.com/dmitryikh/leaves
leaves is a library implementing prediction code for GBRT (Gradient Boosting Regression Trees) models in pure Go. The goal of the project - make it possible to use models from popular GBRT frameworks in Go programs without C API bindings.
NOTE: Before 1.0.0
release the API is a subject to change.
text
format and from JSON
formatgbdt
, rf
(random forest) and dart
modelsgbtree
, gblinear
, dart
modelsnan
)0
)sklearn.ensemble.GradientBoostingClassifier
In order to start, go get this repository:
go get github.com/dmitryikh/leaves
Minimal example:
package main
import (
"fmt"
"github.com/dmitryikh/leaves"
)
func main() {
// 1. Read model
useTransformation := true
model, err := leaves.LGEnsembleFromFile("lightgbm_model.txt", useTransformation)
if err != nil {
panic(err)
}
// 2. Do predictions!
fvals := []float64{1.0, 2.0, 3.0}
p := model.PredictSingle(fvals, 0)
fmt.Printf("Prediction for %v: %f\n", fvals, p)
}
In order to use XGBoost model, just change leaves.LGEnsembleFromFile
, to leaves.XGEnsembleFromFile
.
Documentation is hosted on godoc (link). Documentation contains complex usage examples and full API reference. Some additional information about usage examples can be found in leaves_test.go.
Most leaves features are tested to be compatible with old and coming versions of GBRT libraries. In compatibility.md one can found detailed report about leaves correctness against different versions of external GBRT libraries.
Some additional information on new features and backward compatibility can be found in NOTES.md.
Below are comparisons of prediction speed on batches (~1000 objects in 1 API
call). Hardware: MacBook Pro (15-inch, 2017), 2,9 GHz Intel Core i7, 16 ГБ
2133 MHz LPDDR3. C API implementations were called from python bindings. But
large batch size should neglect overhead of python bindings. leaves
benchmarks were run by means of golang test framework: go test -bench
. See
benchmark for mode details on measurments. See
testdata/README.md for data preparation pipelines.
Single thread:
Test Case | Features | Trees | Batch size | C API | leaves |
---|---|---|---|---|---|
LightGBM MS LTR | 137 | 500 | 1000 | 49ms | 51ms |
LightGBM Higgs | 28 | 500 | 1000 | 50ms | 50ms |
LightGBM KDD Cup 99* | 41 | 1200 | 1000 | 70ms | 85ms |
XGBoost Higgs | 28 | 500 | 1000 | 44ms | 50ms |
4 threads:
Test Case | Features | Trees | Batch size | C API | leaves |
---|---|---|---|---|---|
LightGBM MS LTR | 137 | 500 | 1000 | 14ms | 14ms |
LightGBM Higgs | 28 | 500 | 1000 | 14ms | 14ms |
LightGBM KDD Cup 99* | 41 | 1200 | 1000 | 19ms | 24ms |
XGBoost Higgs | 28 | 500 | 1000 | ? | 14ms |
(?) - currenly I'm unable to utilize multithreading form XGBoost predictions by means of python bindings
(*) - KDD Cup 99 problem involves continuous and categorical features simultaneously
GradientBoostingClassifier.decision_function
)0
is supportedIn case if you are interested in the project or if you have questions, please contact with me by
email: khdmitryi at
gmail.com
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.