Git Product home page Git Product logo

bonsai-1's Introduction

Build Status

Bonsai, a library to parse and evaluate decision trees encoded as JSON

This code allows to export Gradient Boosted Tree Model generated by gbm into a file in JSON format and to evaluate them on new data outside R.

We have been using it inside our company to deploy gbm-trained model into production, either evaluating the JSON directly using the scala code or by generating C++ code from the JSON and deploying the generated code.

Instructions

You can follow the script under src/test/R/test.R' to see how to create a gbm model and convert it to JSON using the script under src/main/R/gmb.R`. The example uses the the model from gbm's help page (except I reduced the number of trees from 1000 to 100 in order to keep the files small) to prepare a test case for the scala unit testing code.

Notes

gbm handles ordered categorical factors as numeric variables and it requires careful handling when converting to JSON. I actually represent the conditional as set operators in the JSON files in order to preserve the categorical nature of the variables.

Dependencies:

  • play-json

Steps:

  • Build the package: mvn clean package

  • Run the Bonsai tool: java -jar target/bonsai-1.0-jar-with-dependencies.jar

    Usage: to pretty-print a json moodel: Bonsai -p modelFile to evaluate a model over a test file: Bonsai -e modelFile dataFile to generate C++ code: Bonsai -c (modelFile)*

  • To convert the model json file to cpp file:

    java -jar target/bonsai-1.0-jar-with-dependencies.jar 'model1 json file' 'model2 json file' ...

Contributors

  • Alex Cozzi
  • Mirek Melichar
  • Amit Jaiswal
  • mijiang
  • Marco Pennacchiotti

bonsai-1's People

Contributors

acozziebay avatar mpennacchiotti avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.