orf

OCaml Random Forests
IN THIS PACKAGE
Module Orf . RFR
module IntMap = BatMap.Int
type features = int IntMap.t
type dep_var = float
type sample = features * dep_var
type tree =
| Leaf of dep_var
| Node of tree * int * int * tree
type metric =
| MSE
| MAE
| MAD
type forest = (tree * int array) array
val train : int -> Random.State.t -> metric -> int -> RFC.int_or_float -> int -> RFC.int_or_float -> int -> sample array -> forest

train ncores rng metric ntrees max_features card_features max_samples min_node_size training_set

val predict_one : int -> forest -> sample -> dep_var * float

(pred_avg, pred_std_dev) = predict_one ncores trained_forest sample

val predict_many : int -> forest -> sample array -> (dep_var * float) array

like predict_one but for an array of samples

val predict_OOB : forest -> sample array -> (dep_var * dep_var) array

use a trained forest to predict on the Out Of Bag (OOB) training set of each tree. The training_set must be provided in the same order than when the model was trained. Can be used to get a reliable model performance estimate, even if you don't have a left out test set. truth_preds = predict_OOB forest training_set

val r2 : (dep_var * dep_var) array -> float

r2 truth_preds: coefficient of determination R^2

val drop_OOB : forest -> forest

make trained model forget OOB samples (reduce model size)

type filename = string
val save : filename -> forest -> unit

Save model to file (Marshal). OOB samples are dropped prior to saving the model.

val restore : filename -> forest

Restore model from file (Marshal)