Suppose I have the following tree structure:
type Tree =
| Branch of (string*string) * (Tree*Tree)
| Leaf of float
For example, it could look something like this:
Branch (("X1",">4.5"), (Branch (("X2",">4.5"), (Leaf 3.4, Leaf 5.5)), Branch (("X3",">4.5"), (Leaf 6.5, Leaf 4.5))))
What would be the essential parts of a function to create a tree like this (from data, randomly, or whatever)? I know my question is similar to how to make a tree from a given data with F#, but I'm having the hardest time translating to my tree.
Edit: I'm trying to build a decision tree, and I started with the tree here which looks like this:
type DecisionTreeNode =
// Attribute name and value / child node list
| DecisionNode of string * (string * DecisionTreeNode) seq
// Decision and corresponding evidence
| Leaf of bool * Record seq
However, mine is a regression tree, so it should have leafs of float, and I only want binary splits, so I thought I could use tuple instead of seq for the nodes. After looking at that tree again, I'm wondering if mine should look like this:
type Tree =
| Branch of string*((string*Tree)*(string*Tree))
| Leaf of float