RandomForest
Random forest algorithm
forest := RandomForest->New(8);
forest->Train(0.3, data);
result := forest->Query(data);
possible := Bool->Rows(result)->As(Float);
matched := DecisionTree->Matches(result->Columns() - 1, result)->As(Float);
matched_perc := (matched / possible * 100.0)->As(Int);
"matched {$matched_perc}%"->PrintLine();
Operations
Load
Loads a saved random forest
function : Load(filename:String) ~ RandomForest
Parameters
Name | Type | Description |
---|---|---|
filename | String | file to store to |
Return
Type | Description |
---|---|
RandomForest | random forest |
New
Constructor
New(num_trees:Int)
Parameters
Name | Type | Description |
---|---|---|
num_trees | Int | number of trees to generate |
Query
Splits a matrix based on a list of decisions
method : public : native : Query(input:BoolMatrixRef) ~ Bool[,]
Parameters
Name | Type | Description |
---|---|---|
input | BoolMatrixRef | matrix to be split |
Return
Type | Description |
---|---|
Bool | split matrix |
Query
Splits a matrix based on a list of decisions
method : public : native : Query(input:Bool[,]) ~ Bool[,]
Parameters
Name | Type | Description |
---|---|---|
input | Bool | matrix to be split |
Return
Type | Description |
---|---|
Bool | split matrix |
Store
Saves a random forest
method : public : Store(filename:String) ~ Bool
Parameters
Name | Type | Description |
---|---|---|
filename | String | file to save to |
Return
Type | Description |
---|---|
Bool | true if successful, false otherwise |
Train
Calculates a list of decision splits
method : public : native : Train(split_perc:Float, input:BoolMatrixRef) ~ Nil
Parameters
Name | Type | Description |
---|---|---|
split_perc | Float | percentage of data to use for training |
input | BoolMatrixRef | training matrix |