xgboost

Machine learning using XGBoost

2 releases

0.1.2 Oct 1, 2018
0.1.1 Oct 1, 2018

#49 in Machine learning

Download history 15/week @ 2018-10-02 5/week @ 2018-10-09 38/week @ 2018-10-16 5/week @ 2018-10-23 4/week @ 2018-10-30 16/week @ 2018-11-06 6/week @ 2018-11-13 4/week @ 2018-11-20 4/week @ 2018-11-27 4/week @ 2018-12-04

5 downloads per month

MIT license

1.5MB
27K SLoC

C++ 19K SLoC // 0.1% comments Python 5K SLoC // 0.1% comments Rust 2K SLoC // 0.3% comments Java 802 SLoC // 0.2% comments Shell 552 SLoC // 0.2% comments R 121 SLoC // 0.2% comments JavaScript 18 SLoC Batch 3 SLoC

rust-xgboost

Travis Build Status Documentation link

Rust bindings for the XGBoost gradient boosting library.

Basic usage example:

extern crate xgboost;

use xgboost::{parameters, dmatrix::DMatrix, booster::Booster};

fn main() {
    // training matrix with 5 training examples and 3 features
    let x_train = &[1.0, 1.0, 1.0,
                    1.0, 1.0, 0.0,
                    1.0, 1.0, 1.0,
                    0.0, 0.0, 0.0,
                    1.0, 1.0, 1.0];
    let num_rows = 5;
    let y_train = &[1.0, 1.0, 1.0, 0.0, 1.0];

    // convert training data into XGBoost's matrix format
    let mut dtrain = DMatrix::from_dense(x_train, num_rows).unwrap();

    // set ground truth labels for the training matrix
    dtrain.set_labels(y_train).unwrap();

    // test matrix with 1 row
    let x_test = &[0.7, 0.9, 0.6];
    let num_rows = 1;
    let y_test = &[1.0];
    let mut dtest = DMatrix::from_dense(x_test, num_rows).unwrap();
    dtest.set_labels(y_test).unwrap();

    // build overall training parameters
    let params = parameters::ParametersBuilder::default().build().unwrap();

    // specify datasets to evaluate against during training
    let evaluation_sets = &[(&dtrain, "train"), (&dtest, "test")];

    // train model, and print evaluation data
    let bst = Booster::train(&params, &dtrain, 3, evaluation_sets).unwrap();

    println!("{:?}", bst.predict(&dtest).unwrap());
}

See the examples directory for more detailed examples of different features.

Status

Currently in a very early stage of development, so the API is changing as usability issues occur, or new features are supported.

Builds against XGBoost 0.80.

Platforms

Tested:

  • Linux
  • Mac OS

Unsupported:

  • Windows

Dependencies

~4MB
~73K SLoC