xgb2code

command module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: Apache-2.0, MIT Imports: 10 Imported by: 0

README

xgb2code

xgb2code - generate code for an XGB model

Description

This program takes an XGB model (in JSON format) and generates code for it.

Generating code for a model avoids having to call out to a different language (e.g., C) as well as avoids the need for using the XGB libraries at runtime.

Model Support

Currently binary classification is supported.

Supported Languages

Currently xgb2code supports generating Go code.

Usage

$ ./xgb2code -h
Usage of ./xgb2code:
  -function-name string
        The function name to use. Must be a valid Go function name.
  -go-package-name string
        The package name to use when generating Go code. Must be a valid Go package name.
  -input-json string
        Path to the model as JSON
  -language string
        Language to generate code for. Currently 'go' is supported. (default "go")
  -output-file string
        The file to write to

Example Usage

$ ./xgb2code -function-name predict \
             -go-package-name main
             -input-json testdata/small-model/model.json \
             -language go \
             -output-file predict.go

produces a file predict.go where the primary model prediction function has the signature:

func predict(data []*float32, predMargin bool) float32 {

Installation

Release binaries and packages have been made available for several popular platforms. Simply download the binary for your platform and run it.

Bug Reports

Please report bugs by filing an issue with our GitHub issue tracker at https://github.com/maxmind/xgb2code/issues.

This software is Copyright (c) 2022 by MaxMind, Inc.

This is free software, licensed under the Apache License, Version 2.0 or the MIT License, at your option.

Documentation

Overview

xgb2code generates code for an XGB model.

Jump to

Keyboard shortcuts

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