I want to use the accord.net framework to generate a decision tree from a set of data.
I read the guide in this link http://crsouza.blogspot.com/2012/01/decision-trees-in-c.html
I was able to generate the tree by following it. However How to use it to predict new inputs?
what i mean is after creating the tree i want to use it (as a if-else statement to know the output of new inputs)
it is stated that I can convert it to an expression var expression = tree.ToExpression();
but how can I use it ?
Thanks for any help
I suggest you read the example in the guide carefully. At the very end of the procedure they generate the expression tree with var expression = tree.ToExpression();
and compile it:
var func = expression.Compile();
The result is a delegate that you can simply execute to get a decision for a given input. In the example, you could do something like
bool willPlayTennis = func(new double[] {1.0, 1.0, 1.0, 1.0}) == 1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With