random-forests
A Rust library for Random Forests.
Support for generic impurity measures:
[x] Entropy [x] Gini
installation
Add to your Cargo.toml
:
randomforests = "*"
usage
Add the crate and RandomForests
to your code:
extern crate randomforests;
use RandomForest;
Create a Dataset
as collection of Item
s:
let mut dataset = new;
let mut item1 = new;
item1.insert;
item1.insert;
dataset.push;
let mut item2 = new;
item2.insert;
item2.insert;
dataset.push;
let mut item3 = new;
item3.insert;
item3.insert;
dataset.push;
Initialise the classifier and train it classifier by passing the Dataset
, a TreeConfig
, the number of trees and the data subsample size:
let mut config = new;
config.decision = "lang".to_string;
let forest = build;
Create a question as an Item
:
let mut question = new;
question.insert;
And get the predictions:
let answer = predict;
// answer = {Value { data: haskell }: 48, Value { data: rust }: 52}