Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use the generated decision tree to predict new inputs

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

like image 299
Y2theZ Avatar asked Oct 08 '22 08:10

Y2theZ


1 Answers

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;

like image 149
Matthias Avatar answered Oct 10 '22 02:10

Matthias