Crate xgboost[][src]

Rust wrapper around the XGBoost machine learning library.

Provides a high level interface for training machine learning models using gradient boosting.

Currently in the early stages of development, API is likely to be fairly unstable as new features are added.

Basic usage example

extern crate xgboost;

use xgboost::{parameters, DMatrix, 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

    // 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();

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

    // specify overall training setup
    let training_params = parameters::TrainingParametersBuilder::default()

    // train model, and print evaluation data
    let bst = Booster::train(&training_params).unwrap();

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

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



Builders for parameters that control various aspects of training.



Core model in XGBoost, containing functions for training, evaluating and predicting.


Data matrix used throughout XGBoost for training/predicting Booster models.


Maps a feature index to a name and type, used when dumping models as text.


Wrap errors returned by the XGBoost library.



Indicates the type of a feature, used when dumping models as text.

Type Definitions


Convenience return type for most operations which can return an XGBError.