Send Close Add comments: (status displays here)
Got it!  This site "www.robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
Decision trees
by RS  admin@robinsnyder.com : 1024 x 640


1. Decision trees
A decision tree allows one to quantify decisions that need to be made.

Let us look at a simple "fix-it" decision tree for something that may or may not work properly and what might need to be done to make it work properly.

The simplest decision trees assume only two possibilities at each decision point are event point (state of nature).

2. Does it move?
The first question is: "does it move?". First decisionThe possibilities here are "yes" or "no". In a one level binary decision tree, there is one decision and two outcomes. The "yes" corresponds to a "true" result and the "no" corresponds to a "false" result.

3. Example program
Here is the C code [#1]


4. Examples of input and output
Here are some examples of input and output for the above program code.

Here is an example input.

For the above example input, here is the expected output.

Here is an example input.

For the above example input, here is the expected output.


5. Should it move
Should it move? Second decisionThe possibilities here are "yes" or "no". In a two level binary decision tree, there are two decisions and four possible outcomes. We now look at each of the four possible outcomes.


6. True positive
If we get a "yes, yes" we have a true positive. In this case, there is no logical problem. True positiveNote: If you test positive for cancer and you actually have cancer, then this is a true positive. There is no logical problem here even though the result is a tragedy from a personal perspective.

7. True negative
If we get a "no, no" we have a true negative. In this case, there is no logical problem. True negative

8. False positive
If we get a "yes, no" we have a false positive. This is a logical problem. False positiveThe solution here may be to use "duct tape" (to keep it from moving).

9. False negative
If we get a "no, yes" we have a false negative. This is a logical problem. False negativeThe solution here may be to use "WD-40" (to help it to move).


10. Decision tree
Here is the fix-it decision tree. Decision treeTo further quantify what is happening, one can place or estimate probabilities for each yes-no decision.

11. Code examples
Below are some code examples of the above decision tree concepts. Note: There are many ways in which these ideas could be programmed.

Often, "yes" is used for "true" and "no" is used for "false". So the above becomes the following.

12. Example program
Here is the C code [#2]


13. Examples of input and output
Here are some examples of input and output for the above program code.

Here is an example input.

For the above example input, here is the expected output.

Here is an example input.

For the above example input, here is the expected output.

Here is an example input.

For the above example input, here is the expected output.

Here is an example input.

For the above example input, here is the expected output.


14. Processing
Normally, the if-then-else processing would be done in the processing part of the code.

C does not handle string processing very well.

So, in this course, some of the processing may be done in the output section of the code.

15. End of page

by RS  admin@robinsnyder.com : 1024 x 640