All Bundles
DecisionTree
Binary decision tree algorithm
Operations
Code example:
data := BoolMatrixRef->New([
[true, false, true]
[true, false, true]
[true, true, true]
[true, true, true]
[true, true, true]
[true, true, true]
[true, true, true]
[true, true, true]
[false, true, true]
[false, true, true]
[true, true, false]
[true, true, false]
[false, true, false]
[false, true, false]
[false, true, false]
[false, true, false]
[false, false, false]
[false, false, false]
[false, false, false]
[false, false, false]
]);
split_data := data->Split(0.3);
training_data := split_data[0];
test_data := split_data[1];
decisions := DecisionTree->Split(training_data->Get());
result := DecisionTree->Decide(decisions, test_data->Get());
possible := result->Rows()->As(Float);
acheived := DecisionTree->Matches(2, result)->As(Float);
(acheived / possible)->PrintLine();
Gini
Calculates the Gini index
function : native : Gini(acheived:Float, goal:Float) ~ Float
Parameters
Name | Type | Description |
---|
acheived | Float | number acheived |
goal | Float | achievement target |
Return
Type | Description |
---|
Float | Gini index |
LoadCsv
Loads a boolean input matrix from a CSV file of 1s and 0s
function : LoadCsv(filename:String) ~ Bool[,]
Parameters
Name | Type | Description |
---|
filename | String | CSV file to load |
Return
Type | Description |
---|
Bool[,] | boolean matrix |
Matches
Count matches in a column
function : Matches(index:Int, matrix:Bool[,]) ~ Int
Parameters
Name | Type | Description |
---|
index | Int | column index |
matrix | Bool[,] | matrix matrix to inspect |
Return
Type | Description |
---|
Int | number of matches |
Mismatches
Count mismatches in a column
function : Mismatches(index:Int, matrix:Bool[,]) ~ Int
Parameters
Name | Type | Description |
---|
index | Int | column index |
matrix | Bool[,] | matrix matrix to inspect |
Return
Type | Description |
---|
Int | number of mismatches |
Query
Splits a matrix based on a list of decisions
function : native : Query(decisions:Vector<Split>, input:Bool[,]) ~ Bool[,]
Parameters
Name | Type | Description |
---|
decisions | Vector<Split> | list of decisions |
input | Bool[,] | matrix to be split |
Return
Split
Splits a matrix along the given column
function : native : Split(index:Int, input:Bool[,]) ~ Bool[,]
Parameters
Name | Type | Description |
---|
index | Int | index used to split |
input | Bool[,] | matrix to split |
Return
Train
Calculates a list of decision splits
function : native : Train(input:Bool[,]) ~ Vector<Split>
Parameters
Name | Type | Description |
---|
input | Bool[,] | training matrix |
Return
Type | Description |
---|
Vector<Split> | list of decision tree splits |