package orf

  1. Overview
  2. Docs

Module Orf.RFRSource

Sourcemodule IntMap = BatMap.Int
Sourcetype features = int IntMap.t
Sourcetype dep_var = float
Sourcetype sample = features * dep_var
Sourcetype tree =
  1. | Leaf of dep_var
  2. | Node of tree * int * int * tree
Sourcetype metric =
  1. | MSE
  2. | MAE
  3. | MAD
Sourcetype forest = (tree * int array) array
Sourceval 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

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

(pred_avg, pred_std_dev) = predict_one ncores trained_forest sample

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

like predict_one but for an array of samples

Sourceval 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

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

r2 truth_preds: coefficient of determination R^2

Sourceval drop_OOB : forest -> forest

make trained model forget OOB samples (reduce model size)

Sourcetype filename = string
Sourceval save : filename -> forest -> unit

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

Sourceval restore : filename -> forest

Restore model from file (Marshal)

OCaml

Innovation. Community. Security.