Random Forest Based on C4.5 Decision Trees

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//load data from a CSV file
var data = DecisionTable.Load("german.data", FileFormat.CSV);

DecisionTable train, test;
var splitter = new DataSplitterRatio(data, 0.8);
splitter.Split(out train, out test);

//Initialize and Learn Random Forest
var forest = new DecisionForestRandom<DecisionTreeC45>();
forest.Size = 500;
forest.Learn(train, train.SelectAttributeIds(a => a.IsStandard).ToArray());

//Validate on test data set
var result = Classifier.Default.Classify(forest, test);

//Output the results
Console.WriteLine(result);
Written on June 27, 2017